GameServerQueryPort

GameServerQueryPort

#Overview

name: GameServerQueryPort

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 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of GameServerQueryPort is to manage server browser-related duties and information in the Steamworks integration for Unreal Engine. This variable represents the query port used by the Steam game server for handling server browser requests and providing server information.

This setting variable is primarily used by the Online Subsystem Steam plugin, which is part of Unreal Engine’s networking and online services framework. Specifically, it is utilized within the FOnlineSubsystemSteam class, which implements the Steam-specific functionality for online features.

The value of this variable is set in multiple ways:

  1. It can be read from the command line using the “QueryPort=” parameter.
  2. If not specified in the command line, it is read from the GEngineIni configuration file under the “OnlineSubsystemSteam” section with the key “GameServerQueryPort”.
  3. If neither of the above methods provides a value, it defaults to 27015.
  4. It is also set programmatically when initializing the Steamworks server using the SteamAPIServerHandle->GetQueryPort() function.

GameServerQueryPort interacts with other variables such as GameServerGamePort, which represents the main game port used by the server.

Developers must be aware that:

  1. This port is separate from the main game port and is specifically used for server browser and query-related communications.
  2. The value should be unique and not conflict with other services or games running on the same machine.
  3. Firewall settings may need to be adjusted to allow incoming connections on this port.

Best practices when using this variable include:

  1. Ensuring that the query port is properly configured in both the game code and any server management tools or scripts.
  2. Documenting the chosen query port for server administrators and players who may need to configure their networks accordingly.
  3. Considering using a configurable value rather than hardcoding it, allowing for flexibility in different deployment scenarios.
  4. Verifying that the query port is open and accessible when troubleshooting server discovery issues.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2244, section: [OnlineSubsystemSteam]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Private/OnlineSubsystemSteam.cpp:668

Scope (from outer to inner):

file
function     bool FOnlineSubsystemSteam::InitSteamworksServer

Source code excerpt:

		// Grab the port values so that we save them.
		GameServerGamePort = SteamAPIServerHandle->GetGamePort();
		GameServerQueryPort = SteamAPIServerHandle->GetQueryPort();

		// Test all the Steam interfaces
		#define GET_STEAMWORKS_INTERFACE(Interface) \
		if (Interface() == nullptr) \
		{ \
			UE_LOG_ONLINE(Warning, TEXT("Steamworks: %s() failed!"), TEXT(#Interface)); \

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Public/OnlineSubsystemSteam.h:75

Scope (from outer to inner):

file
class        class FOnlineSubsystemSteam : public FOnlineSubsystemImpl

Source code excerpt:


	/** Query port - the port that will manage server browser related duties and info */
	int32 GameServerQueryPort;

	/** Array of the files in the cloud for a given user */
	TArray<struct FSteamUserCloudData*> UserCloudData;

	/** Interface to the session services */
	FOnlineSessionSteamPtr SessionInterface;

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Public/OnlineSubsystemSteam.h:152

Scope (from outer to inner):

file
class        class FOnlineSubsystemSteam : public FOnlineSubsystemImpl
function     FOnlineSubsystemSteam

Source code excerpt:

		SteamAppID(0),
		GameServerGamePort(0),
		GameServerQueryPort(0),
		SessionInterface(nullptr),
		IdentityInterface(nullptr),
		FriendInterface(nullptr),
		SharedCloudInterface(nullptr),
		UserCloudInterface(nullptr),
		LeaderboardsInterface(nullptr),

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Public/OnlineSubsystemSteam.h:345

Scope (from outer to inner):

file
class        class FOnlineSubsystemSteam : public FOnlineSubsystemImpl
function     inline int32 GetGameServerQueryPort

Source code excerpt:

	inline int32 GetGameServerQueryPort() const
	{
		return GameServerQueryPort;
	}

	/**
	 *	@return if this subsystem is using SteamNetworking functionality 
	 *			or another network layer like SteamSockets
	 */

#Loc: <Workspace>/Engine/Plugins/Runtime/Steam/SteamShared/Source/SteamShared/Private/SteamSharedModule.cpp:328

Scope (from outer to inner):

file
function     FSteamServerInstanceHandler::FSteamServerInstanceHandler

Source code excerpt:

	if (FParse::Value(FCommandLine::Get(), TEXT("QueryPort="), QueryPort) == false)
	{
		if (!GConfig->GetInt(TEXT("OnlineSubsystemSteam"), TEXT("GameServerQueryPort"), QueryPort, GEngineIni))
		{
			QueryPort = 27015;
		}
	}

	// Set VAC