net.DoHandshakeVersionFallback

net.DoHandshakeVersionFallback

#Overview

name: net.DoHandshakeVersionFallback

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of net.DoHandshakeVersionFallback is to control whether the client should attempt to fall back to previous versions of the handshake protocol when a handshake failure occurs. This setting is part of Unreal Engine’s networking system, specifically related to the stateless connect handler component.

This setting variable is primarily used in the Engine module, specifically within the StatelessConnectHandlerComponent. It’s part of the networking subsystem of Unreal Engine 5.

The value of this variable is set through a console variable (CVar) named CVarNetDoHandshakeVersionFallback. It’s initialized with a default value of 0, meaning the fallback behavior is disabled by default.

This variable interacts with other networking-related variables, particularly those related to handshake versioning. It’s used in conjunction with MinSupportedHandshakeVersion and CurrentHandshakeVersion to determine the range of protocol versions to attempt during fallback.

Developers must be aware that enabling this setting (by setting it to a non-zero value) can impact network security and compatibility. It allows the client to attempt connections using older handshake protocols, which might have been deprecated for security or functionality reasons.

Best practices when using this variable include:

  1. Keeping it disabled (set to 0) in production environments to ensure the most up-to-date and secure handshake protocol is used.
  2. Only enabling it for debugging or testing purposes when dealing with version incompatibility issues.
  3. When enabled, monitoring network traffic and connection attempts closely to understand its impact.

Regarding the associated variable CVarNetDoHandshakeVersionFallback:

The purpose of CVarNetDoHandshakeVersionFallback is to provide a console-accessible way to control the net.DoHandshakeVersionFallback setting. It’s an implementation detail of how the setting is exposed to the engine’s console variable system.

This variable is defined and used within the same Engine module, specifically in the StatelessConnectHandlerComponent.

The value of CVarNetDoHandshakeVersionFallback is set when the engine initializes its console variables. It can be changed at runtime through console commands.

It directly controls the behavior of the handshake version fallback feature. When queried (using GetValueOnAnyThread()), it determines whether the fallback logic should be executed.

Developers should be aware that changes to this variable take effect immediately and can be made at runtime, potentially affecting ongoing network operations.

Best practices for CVarNetDoHandshakeVersionFallback include:

  1. Using it for quick testing and debugging of network issues related to handshake versioning.
  2. Resetting it to its default value (0) after testing to ensure normal operation.
  3. Documenting any changes made to this variable during development or support processes.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PacketHandlers/StatelessConnectHandlerComponent.cpp:272

Scope (from outer to inner):

file
namespace    UE::Net

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarNetDoHandshakeVersionFallback(
		TEXT("net.DoHandshakeVersionFallback"),
		0,
		TEXT("Whether or not to (clientside) perform randomized falling-back to previous versions of the handshake protocol, upon failure."));

	static int32 GHandshakeEnforceNetworkCLVersion = 0;

	static FAutoConsoleVariableRef CVarNetHandshakeEnforceNetworkCLVersion(

#Associated Variable and Callsites

This variable is associated with another variable named CVarNetDoHandshakeVersionFallback. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PacketHandlers/StatelessConnectHandlerComponent.cpp:271

Scope (from outer to inner):

file
namespace    UE::Net

Source code excerpt:

		TEXT("The current supported stateless handshake protocol version (numeric)"));

	static TAutoConsoleVariable<int32> CVarNetDoHandshakeVersionFallback(
		TEXT("net.DoHandshakeVersionFallback"),
		0,
		TEXT("Whether or not to (clientside) perform randomized falling-back to previous versions of the handshake protocol, upon failure."));

	static int32 GHandshakeEnforceNetworkCLVersion = 0;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PacketHandlers/StatelessConnectHandlerComponent.cpp:1821

Scope (from outer to inner):

file
function     void StatelessConnectHandlerComponent::Tick

Source code excerpt:

					// (we don't know if the server supports the minimum version either, so pick from the full range).
					// It's better for devs to explicitly hotfix the 'net.MinHandshakeVersion' value, instead of relying upon this fallback.
					if (!!CVarNetDoHandshakeVersionFallback.GetValueOnAnyThread() && FMath::RandBool())
					{
						// Decrement the minimum version, based on the number of handshake packets sent - to select for higher supported versions
						const int32 MinVersion = FMath::Max(MinSupportedHandshakeVersion, CurrentHandshakeVersion - SentHandshakePacketCount);

						if (MinVersion != CurrentHandshakeVersion)
						{