ConnectToEndpoints
ConnectToEndpoints
#Overview
name: ConnectToEndpoints
The value of this variable can be defined or overridden in .ini config files. 2
.ini config files referencing this setting variable.
It is referenced in 10
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ConnectToEndpoints is to specify a list of remote endpoints that the Unreal Engine messaging system should connect to for communication. This variable is primarily used in the context of network communication and messaging systems within Unreal Engine 5.
ConnectToEndpoints is utilized by the WebSocket Messaging and TCP Messaging plugins/modules in Unreal Engine. These subsystems rely on this setting variable to establish outgoing connections to specified remote endpoints.
The value of this variable is typically set in the project settings or configuration files. It can be modified through the Unreal Engine Editor or programmatically in C++ code.
ConnectToEndpoints interacts with other variables such as ListenEndpoint, ConnectionRetryDelay, and ConnectionRetryPeriod. These variables work together to manage the network connections and communication behavior.
Developers must be aware that:
- The endpoints should be specified in the correct format (e.g., “ws://example.com/xyz” for WebSocket or IP:Port for TCP).
- Invalid endpoint entries will be ignored with a warning message logged.
- The variable is used in both WebSocket and TCP messaging systems, so care should be taken to use the appropriate format for the chosen messaging system.
Best practices when using this variable include:
- Ensure that the specified endpoints are reachable and compatible with the chosen messaging system.
- Regularly review and update the endpoints as needed to maintain proper network communication.
- Use appropriate security measures, such as HTTPS for WebSocket connections, when dealing with sensitive data.
- Consider implementing error handling and reconnection logic to manage potential connection issues.
- Be mindful of the number of endpoints specified, as connecting to too many endpoints may impact performance.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:3363, section: [/Script/TcpMessaging.TcpMessagingSettings]
- INI Section:
/Script/TcpMessaging.TcpMessagingSettings
- Raw value:
CLEAR_ARRAY
- Is Array:
True
Location: <Workspace>/Engine/Config/Android/AndroidEngine.ini:47, section: [/Script/TcpMessaging.TcpMessagingSettings]
- INI Section:
/Script/TcpMessaging.TcpMessagingSettings
- Raw value:
CLEAR_ARRAY
- Is Array:
True
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Experimental/WebSocketMessaging/Source/WebSocketMessaging/Private/WebSocketMessageTransport.cpp:77
Scope (from outer to inner):
file
function bool FWebSocketMessageTransport::StartTransport
Source code excerpt:
}
for (const FString& Url : Settings->ConnectToEndpoints)
{
FGuid Guid = FGuid::NewGuid();
TMap<FString, FString> Headers;
Headers.Add(WebSocketMessaging::Header::TransportId, Guid.ToString());
for (const TPair<FString, FString>& Pair : Settings->HttpHeaders)
#Loc: <Workspace>/Engine/Plugins/Experimental/WebSocketMessaging/Source/WebSocketMessaging/Private/WebSocketMessagingSettings.h:36
Scope (from outer to inner):
file
class class UWebSocketMessagingSettings : public UObject
Source code excerpt:
/** The WebSocket Urls to connect to (Eg. ws://example.com/xyz) */
UPROPERTY(config, EditAnywhere, Category = Transport)
TArray<FString> ConnectToEndpoints;
/** Additional HTTP headers to set when connecting to endpoints */
UPROPERTY(config, EditAnywhere, Category = Transport)
TMap<FString, FString> HttpHeaders;
};
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Settings/TcpMessagingSettings.h:52
Scope (from outer to inner):
file
class class UTcpMessagingSettings : public UObject
Source code excerpt:
*/
UPROPERTY(config, EditAnywhere, Category=Transport)
TArray<FString> ConnectToEndpoints;
/**
* Delay time between attempts to re-establish outgoing connections that become disconnected or fail to connect
* 0 disables reconnection
*/
UPROPERTY(config, EditAnywhere, Category = Transport)
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/TcpMessagingModule.cpp:194
Scope (from outer to inner):
file
class class FTcpMessagingModule : public FSelfRegisteringExec , public ITcpMessagingModule
function void InitializeBridge
Source code excerpt:
FIPv4Endpoint ListenEndpoint;
TArray<FIPv4Endpoint> ConnectToEndpoints;
FString ListenEndpointString = Settings->GetListenEndpoint();
if (!FIPv4Endpoint::Parse(ListenEndpointString, ListenEndpoint))
{
if (!ListenEndpointString.IsEmpty())
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/TcpMessagingModule.cpp:216
Scope (from outer to inner):
file
class class FTcpMessagingModule : public FSelfRegisteringExec , public ITcpMessagingModule
function void InitializeBridge
Source code excerpt:
if (FIPv4Endpoint::Parse(ConnectToEndpointString, ConnectToEndpoint) || FIPv4Endpoint::FromHostAndPort(ConnectToEndpointString, ConnectToEndpoint))
{
ConnectToEndpoints.Add(ConnectToEndpoint);
}
else
{
UE_LOG(LogTcpMessaging, Warning, TEXT("Invalid entry for ConnectToEndpoint '%s', ignoring"), *ConnectToEndpointString);
}
}
FString Status(TEXT("Initializing TcpMessaging bridge"));
if (ConnectToEndpoints.Num())
{
Status += FString::Printf(TEXT(" for %d outgoing connections"), ConnectToEndpoints.Num());
}
if (ListenEndpoint != FIPv4Endpoint::Any)
{
Status += TEXT(", listening on ");
Status += ListenEndpoint.ToText().ToString();
}
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/TcpMessagingModule.cpp:237
Scope (from outer to inner):
file
class class FTcpMessagingModule : public FSelfRegisteringExec , public ITcpMessagingModule
function void InitializeBridge
Source code excerpt:
UE_LOG(LogTcpMessaging, Log, TEXT("%s"), *Status);
TSharedRef<FTcpMessageTransport, ESPMode::ThreadSafe> Transport = MakeShareable(new FTcpMessageTransport(ListenEndpoint, ConnectToEndpoints, Settings->GetConnectionRetryDelay(), Settings->GetConnectionRetryPeriod()));
// Safe weak pointer for adding/removing connections
MessageTransportPtr = Transport;
MessageBridge = FMessageBridgeBuilder().UsingTransport(Transport);
}
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/TcpMessagingModule.cpp:364
Scope (from outer to inner):
file
function void UTcpMessagingSettings::GetConnectToEndpoints
Source code excerpt:
void UTcpMessagingSettings::GetConnectToEndpoints(TArray<FString>& Endpoints) const
{
for (const FString& ConnectEndpoint : ConnectToEndpoints)
{
Endpoints.Add(ConnectEndpoint);
}
FString ConnectString;
if (FParse::Value(FCommandLine::Get(), TEXT("TcpMessagingConnect="), ConnectString, /* bShouldStopOnSeparator */ false))
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Transport/TcpMessageTransport.cpp:17
Scope (from outer to inner):
file
function FTcpMessageTransport::FTcpMessageTransport
Source code excerpt:
FTcpMessageTransport::FTcpMessageTransport(const FIPv4Endpoint& InListenEndpoint, const TArray<FIPv4Endpoint>& InConnectToEndpoints, int32 InConnectionRetryDelay, int32 InConnectionRetryPeriod)
: ListenEndpoint(InListenEndpoint)
, ConnectToEndpoints(InConnectToEndpoints)
, ConnectionRetryDelay(InConnectionRetryDelay)
, ConnectionRetryPeriod(InConnectionRetryPeriod)
, bStopping(false)
, SocketSubsystem(ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM))
, Listener(nullptr)
, TransportHandler(nullptr)
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Transport/TcpMessageTransport.cpp:55
Scope (from outer to inner):
file
function bool FTcpMessageTransport::StartTransport
Source code excerpt:
// outgoing connections
for (auto& ConnectToEndPoint : ConnectToEndpoints)
{
AddOutgoingConnection(ConnectToEndPoint);
}
return true;
}
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Transport/TcpMessageTransport.h:93
Scope (from outer to inner):
file
class class FTcpMessageTransport : FRunnable , public IMessageTransport
Source code excerpt:
/** Current settings */
FIPv4Endpoint ListenEndpoint;
TArray<FIPv4Endpoint> ConnectToEndpoints;
int32 ConnectionRetryDelay;
int32 ConnectionRetryPeriod;
/** For the thread */
bool bStopping;