MessageBus.UDP.ConnectionsToError
MessageBus.UDP.ConnectionsToError
#Overview
name: MessageBus.UDP.ConnectionsToError
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Connections to error out on when MessageBus.UDP.InduceSocketError is enabled.\nThis can be a comma separated list in the form IPAddr2:port,IPAddr3:port
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MessageBus.UDP.ConnectionsToError is to specify a list of UDP connections that should be intentionally errored out when testing error handling in the UDP messaging system of Unreal Engine.
This setting variable is primarily used by the UDP Messaging plugin, which is part of Unreal Engine’s networking and messaging system. Based on the callsites, it’s specifically used in the UdpMessageProcessor.cpp file, which is likely responsible for processing UDP messages.
The value of this variable is set through the console variable system (CVarConnectionsToError). It’s defined with an empty default value, but can be set at runtime or through configuration files.
This variable interacts closely with another console variable, MessageBus.UDP.InduceSocketError. The connections specified in MessageBus.UDP.ConnectionsToError will only be errored out when MessageBus.UDP.InduceSocketError is enabled.
Developers must be aware that:
- This variable is primarily for testing and debugging purposes.
- The value should be a comma-separated list of IP addresses and ports in the format “IPAddr:port,IPAddr2:port”.
- Using this variable in a production environment could cause intentional failures in network communication.
Best practices when using this variable include:
- Only use it in controlled testing environments.
- Always disable it (by setting it to an empty string) before deploying to production.
- Use it in conjunction with logging and error handling tests to ensure the system behaves correctly when network errors occur.
Regarding the associated variable CVarConnectionsToError:
This is the actual console variable object that represents MessageBus.UDP.ConnectionsToError in the code. It’s of type TAutoConsoleVariable
The purpose of CVarConnectionsToError is to provide a programmatic interface to read and potentially modify the MessageBus.UDP.ConnectionsToError setting within the C++ code.
This variable is used directly in the ShouldErrorOnConnection function to determine if a specific endpoint should be errored out. The function parses the string value of CVarConnectionsToError into individual endpoint strings and compares them with the given endpoint.
Developers should be aware that changes to CVarConnectionsToError will immediately affect the behavior of the UDP message processor. They should also note that accessing this variable’s value is thread-safe, as evidenced by the use of GetValueOnAnyThread().
Best practices for using CVarConnectionsToError include:
- Use the provided accessor methods (like GetValueOnAnyThread()) rather than accessing the value directly.
- Consider caching the parsed endpoint list if it’s accessed frequently, to avoid repeated parsing overhead.
- Be cautious when modifying this variable at runtime, as it could have immediate effects on network behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageProcessor.cpp:36
Scope: file
Source code excerpt:
TAutoConsoleVariable<FString> CVarConnectionsToError(
TEXT("MessageBus.UDP.ConnectionsToError"),
TEXT(""),
TEXT("Connections to error out on when MessageBus.UDP.InduceSocketError is enabled.\n")
TEXT("This can be a comma separated list in the form IPAddr2:port,IPAddr3:port"),
ECVF_Default);
TAutoConsoleVariable<int32> CVarCheckForExpiredWithFullQueue(
#Associated Variable and Callsites
This variable is associated with another variable named CVarConnectionsToError
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageProcessor.cpp:35
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<FString> CVarConnectionsToError(
TEXT("MessageBus.UDP.ConnectionsToError"),
TEXT(""),
TEXT("Connections to error out on when MessageBus.UDP.InduceSocketError is enabled.\n")
TEXT("This can be a comma separated list in the form IPAddr2:port,IPAddr3:port"),
ECVF_Default);
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageProcessor.cpp:59
Scope (from outer to inner):
file
namespace UE::Private::MessageProcessor
function bool ShouldErrorOnConnection
Source code excerpt:
}
const FString ConnectionsToErrorString = CVarConnectionsToError.GetValueOnAnyThread();
TArray<FString> EndpointStrings;
ConnectionsToErrorString.ParseIntoArray(EndpointStrings, TEXT(","));
for (const FString& EndpointString : EndpointStrings)
{
FIPv4Endpoint Endpoint;
if (FIPv4Endpoint::Parse(EndpointString, Endpoint))