NetErrorLogInterval

NetErrorLogInterval

#Overview

name: NetErrorLogInterval

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NetErrorLogInterval is to control the frequency of network error logging in Unreal Engine 5. It sets the minimum time interval between consecutive network error log entries, preventing excessive logging and potential performance impacts due to frequent error reporting.

This setting variable is primarily used by the Engine subsystem, specifically within the networking and game viewport components. The main modules that rely on this variable are:

  1. Engine module
  2. GameViewportClient
  3. NetConnection

The value of NetErrorLogInterval is set as a global configuration property (UPROPERTY(globalconfig)) within the UEngine class. This means it can be configured in the engine’s configuration files, allowing developers to adjust it without modifying the source code.

NetErrorLogInterval interacts with the FPlatformTime::Seconds() function to determine if enough time has passed since the last error log to warrant a new log entry. It’s used in conjunction with a static LastTimePrinted variable in each context where it’s applied.

Developers should be aware that:

  1. Setting this value too low may result in excessive logging, which could impact performance or fill up log files quickly.
  2. Setting it too high might cause important network errors to be missed or delayed in reporting.
  3. This variable affects multiple areas of the engine’s networking system, so changes will have a widespread effect.

Best practices when using this variable include:

  1. Adjust the value based on the specific needs of your project. For example, during development and testing, you might want a shorter interval for more detailed logging, while in production, a longer interval might be more appropriate.
  2. Monitor the impact of this setting on your game’s performance and log file sizes.
  3. Consider creating different configurations for development, testing, and production environments.
  4. Use in conjunction with other logging and diagnostics tools to get a comprehensive view of your game’s networking performance.
  5. Regularly review logged errors to identify and address recurring network issues.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:310, section: [/Script/Engine.Engine]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:3110

Scope (from outer to inner):

file
class        class UEngine : public UObject , public FExec

Source code excerpt:

	/** Amount of time in seconds between network error logging */
	UPROPERTY(globalconfig)
	float NetErrorLogInterval;

	/** Spawns all of the registered server actors */
	ENGINE_API virtual void SpawnServerActors(UWorld *World);

	/**
	 * Notification of network error messages, allows the engine to handle the failure

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:2364

Scope (from outer to inner):

file
function     void UGameViewportClient::PeekNetworkFailureMessages

Source code excerpt:

{
	static double LastTimePrinted = 0.0f;
	if (FPlatformTime::Seconds() - LastTimePrinted > GEngine->NetErrorLogInterval)
	{
		UE_LOG(LogNet, Warning, TEXT("Network Failure: %s[%s]: %s"), NetDriver ? *NetDriver->NetDriverName.ToString() : TEXT("NULL"), ENetworkFailure::ToString(FailureType), *ErrorString);
		LastTimePrinted = FPlatformTime::Seconds();
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetConnection.cpp:4499

Scope (from outer to inner):

file
function     void UNetConnection::Tick

Source code excerpt:

		
		static double LastTimePrinted = 0.0f;
		if (FPlatformTime::Seconds() - LastTimePrinted > GEngine->NetErrorLogInterval)
		{
			UE_LOG(LogNet, Warning, TEXT("%s"), *Error);
			LastTimePrinted = FPlatformTime::Seconds();
		}

		HandleConnectionTimeout(Error);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:14108

Scope (from outer to inner):

file
function     void UEngine::HandleNetworkFailure

Source code excerpt:

{
	static double LastTimePrinted = 0.0f;
	if (FPlatformTime::Seconds() - LastTimePrinted > NetErrorLogInterval)
	{
		UE_LOG(LogNet, Log, TEXT("NetworkFailure: %s, Error: '%s'"), ENetworkFailure::ToString(FailureType), *ErrorString);
		LastTimePrinted = FPlatformTime::Seconds();
	}

	if (!NetDriver)