Download

Unable to host listen servers in 4.26

Hi everyone,

I am completely at my wit’s end trying to get listen servers working in 4.26. Dedicated servers work just fine: they are visible to clients and can be joined just fine. However, if the client tries to host a listen server then it fails to properly register with Steam. All the guides I’ve found online are out of date and their advice is obsolete and is no longer valid.

The client starts a listen server like so:

  FString GameModeOption = "?Game=/Game/Maps/GameMode/" + GameModeName + "." + GameModeName + "_C";

  // If the player has ticked the "host online" box then start a listen server
  if (HostOnlineBox->IsChecked()) {
  	GameModeOption.Append("?listen");
  }

  FString MapPath = MapToStart + GameModeOption;

  GetWorld()->ServerTravel(MapPath, true);

This is how the session is being advertised:

IOnlineSubsystem* const OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{

  // Get the Session Interface, so we can call the "CreateSession" function on it
  IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();
  TSharedPtr<FOnlineSessionSettings> SessionSettings = MakeShared<FOnlineSessionSettings>();

  SessionSettings->bAllowJoinInProgress = true;
  SessionSettings->NumPublicConnections = FMath::Clamp(ServerPlayerCount, 1, 250);
  SessionSettings->bAntiCheatProtected = false;
  
  SessionSettings->bShouldAdvertise = true;
  SessionSettings->bAllowJoinViaPresence = true;
  SessionSettings->bAllowJoinViaPresenceFriendsOnly = false;
  SessionSettings->bUsesPresence = true;
  SessionSettings->bIsDedicated = false;
  SessionSettings->bIsLANMatch = false;
  

  SessionSettings->Set(FName("ServerName"), ServerName, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);
  SessionSettings->Set(SETTING_GAMEMODE, InGameMode, EOnlineDataAdvertisementType::ViaOnlineService);
  SessionSettings->Set(SETTING_MAPNAME, InMapName, EOnlineDataAdvertisementType::ViaOnlineService);
  SessionSettings->Set(FName("HasPassword"), (GetServerPassword() != ""), EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);

  // Set the delegate to the Handle of the SessionInterface
  OnCreateSessionCompleteDelegateHandle = Sessions->AddOnCreateSessionCompleteDelegate_Handle(OnCreateSessionCompleteDelegate);
  bool bWasSessionCreated = Sessions->CreateSession(0, GameSessionName, *SessionSettings);
  UE_LOG(LogTemp, Warning, TEXT("CreateWaTSession successful = %s"), (bWasSessionCreated) ? TEXT("True") : TEXT("False"));

}

This is what the log shows is happening when it is supposed to be starting the server:

LogOnlineSession: Warning: STEAM: Empty session setting GameMode : OnlineService of type String
LogOnlineSession: Verbose: STEAM: Lobby Data (OWNINGID, 76561197971928639)
LogOnlineSession: Verbose: STEAM: Lobby Data (OWNINGNAME, [RSE] Neoptolemus)
LogOnlineSession: Verbose: STEAM: Lobby Data (NUMOPENPRIVCONN, 0)
LogOnlineSession: Verbose: STEAM: Lobby Data (NUMOPENPUBCONN, 199)
LogOnlineSession: Verbose: STEAM: Lobby Data (CONMETHOD, P2P)
LogOnlineSession: Verbose: STEAM: Lobby Data (P2PADDR, 76561197971928639)
LogOnlineSession: Verbose: STEAM: Lobby Data (P2PPORT, 7777)
LogOnlineSession: Verbose: STEAM: Lobby Data (NUMPUBCONN, 200)
LogOnlineSession: Verbose: STEAM: Lobby Data (NUMPRIVCONN, 0)
LogOnlineSession: Verbose: STEAM: Lobby Data (SESSIONFLAGS, 195)
LogOnlineSession: Verbose: STEAM: Lobby Data (BUILDID, 0)
LogOnlineSession: Verbose: STEAM: Lobby Data (ServerName_s, My Listen Server)
LogOnlineSession: Verbose: STEAM: Lobby Data (MapName_s, New_Alpha_Map)
LogOnlineSession: Verbose: STEAM: Lobby Data (HasPassword_b, false)
LogOnlineSession: Verbose: OSS: dumping NamedSession:
LogOnlineSession: Verbose: OSS: SessionName: GameSession
LogOnlineSession: Verbose: OSS: HostingPlayerNum: 0
LogOnlineSession: Verbose: OSS: SessionState: Pending
LogOnlineSession: Verbose: OSS: RegisteredPlayers:
LogOnlineSession: Verbose: OSS: 0 registered players
LogOnlineSession: Verbose: OSS: dumping Session:
LogOnlineSession: Verbose: OSS: OwningPlayerName: [RSE] Neoptolemus
LogOnlineSession: Verbose: OSS: OwningPlayerId: [RSE] Neoptolemus [0x177D00D05B0]
LogOnlineSession: Verbose: OSS: NumOpenPrivateConnections: 0
LogOnlineSession: Verbose: OSS: NumOpenPublicConnections: 199
LogOnlineSession: Verbose: OSS: SessionInfo: HostIP: INVALID SteamP2P: 76561197971928639:7777 Type: Lobby session SessionId: Lobby[0x186000005E2B610]
LogOnlineSession: Verbose: OSS: dumping SessionSettings:
LogOnlineSession: Verbose: OSS: NumPublicConnections: 200
LogOnlineSession: Verbose: OSS: NumPrivateConnections: 0
LogOnlineSession: Verbose: OSS: bIsLanMatch: false
LogOnlineSession: Verbose: OSS: bIsDedicated: false
LogOnlineSession: Verbose: OSS: bUsesStats: false
LogOnlineSession: Verbose: OSS: bShouldAdvertise: true
LogOnlineSession: Verbose: OSS: bAllowJoinInProgress: true
LogOnlineSession: Verbose: OSS: bAllowInvites: false
LogOnlineSession: Verbose: OSS: bUsesPresence: true
LogOnlineSession: Verbose: OSS: bAllowJoinViaPresence: true
LogOnlineSession: Verbose: OSS: bAllowJoinViaPresenceFriendsOnly: false
LogOnlineSession: Verbose: OSS: BuildUniqueId: 0x00000000
LogOnlineSession: Verbose: OSS: Settings:
LogOnlineSession: Verbose: OSS: ServerName=My Listen Server : OnlineServiceAndPing
LogOnlineSession: Verbose: OSS: GameMode= : OnlineService
LogOnlineSession: Verbose: OSS: MapName=New_Alpha_Map : OnlineService
LogOnlineSession: Verbose: OSS: HasPassword=false : OnlineServiceAndPing

I am using a source build of the engine, and I have set up all the steps to integrate steam as far as I’m aware:

  • I have enabled the OnlineSubsystem and OnlineSubsystemUtils modules in the PublicDependencyModuleNames, and added OnlineSubsystemNull and OnlineSubsystemSteam to the DynamicallyLoadedModuleNames in Build.cs
  • I have defined global definitions for the UE4 project product name, game directory, game description and steam shipping ID in my project.target.cs and projectserver.target.cs, and set bUsesSteam = true.

I am completely out of ideas and I just don’t understand what I need to do to fix this. I have found people with similar issues, but they said switching to a binary build rather than source build fixed the problem for them, but that didn’t work for me. All it did was make it so the client can no longer see ANY servers, and it still had the same issue hosting a listen server.

Any help would be much appreciated!

SessionSettings->bIsLANMatch = false;
Make that true for listen server.

Have you edited the listen code?
If not then why are you trying to connect on line for a listen server?

My understanding is this, if i am wrong someone correct me.
A listen server is offline but on a closed network as in your home network or your business network. not over the net.

Dedicated is over the online over the net.

bIsLANMatch = listen server, not online and not over the net. but on a home network or your business network. to play amongst friends or workers.

bIsDedicated = dedicated server, online over the net.

My understanding was that a listen server is just a process that runs the server and client code together so that the host can play, as opposed to a dedicated server which doesn’t run any client code at all.

What I want is for players to be able to tick a box when starting a match which means their session will be publically visible in the server browser and can be joined by others online.

Currently, listen servers are neither visible in the browser or joinable by others through console commands, and it looks like the reason is that the engine initially registers the server with Steam, but then for some reason aborts and hosts a standalone session instead.

Unless I’m much mistaken, isn’t changing the LAN setting telling the game to only run the session on the local network? That isn’t what I want to do.

Are you trying to use dedicated servers and listen servers together? AFAIK you should use either one or the other.

That’s just plain wrong lol. Listen servers can be handled by Steam as well (via P2P connection), no need to set bIsLANMatch to true.

That doesn’t sound quite right, surely UE4 allows a game to support both dedicated servers for public matches, and listen servers for private games? Games have been able to do that since the original QuakeWorld.

Assuming it is true, what would I need to do to change the project to support listen servers? I don’t think I’m doing anything special for dedicated server support which would break listen server capability…