Multiplayer Steam LAN - NumOpenPublicConnections does not update

Hello everyone,

So as the title suggests, I have setup a multiplayer game using the OnlineSubsystemSteam, when I create a LAN session and Steam is running (I switch over to use the OnlineSubsystemNull for LAN matches since Steam does not handle that AFAIK) my log on the NumOpenPublicConnections remais the same as max players and does not update after new players join the session (yes they can join over LAN), but if Steam is closed NumOpenPublicConnections does update normally.

The problem is that if I want to check how many players are connected to the session it always returns zero. How can I fix that?

void UHKServerMenu::OnFindSessionsComplete(const bool bWasSuccessful)
	UE_LOG(LogTemp, Warning, TEXT("CALLED %s -- AT LINE :: %d -- bWasSuccessful: %d"), *FString(__FUNCTION__), __LINE__, bWasSuccessful);

	GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Green, FString::Printf(TEXT("UHKServerMenu::OnFindSessionsComplete :: bWasSuccessful: %d"), bWasSuccessful));

	if (bWasSuccessful)
		FoundSessions = HKGameInstance->SessionSearch->SearchResults;
		for (FOnlineSessionSearchResult SessionResult : FoundSessions)
			auto MaxPlayers = SessionResult.Session.SessionSettings.NumPublicConnections;
			auto NumCurrentPlayers = MaxPlayers - SessionResult.Session.NumOpenPublicConnections;
			GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::White, FString::Printf(TEXT("MaxPlayers :: %d - NumCurrentPlayers :: %d"), MaxPlayers, NumCurrentPlayers));
			if (NumCurrentPlayers != MaxPlayers)
				bSessionFound = true;
				AvailableSession = SessionResult;

Hi nullbot, sorry, do you mean you only get this problem for LAN sessions with Steam and it doesn’t occur for internet sessions? Or perhaps you just only tested it for LAN?

I had what was probably the same issue, but I don’t think I ever tested it for LAN, only internet sessions.

Anyway, if it happens for internet sessions too, so far as you’re aware, then I was able to get around it with a small engine modification which I can share with you.

Hi Jonwood regarding to your post could you share the modification with me? I am also running into the problem where the player number inside the room doesn’t update. Thanks!

Hi swfly, sure, I’ll post it as an answer and if it’s a different problem or it doesn’t work, nullbot can just not accept it. I hope it helps you anyway.

Ok, well I had what I assume to be the same issue (although I never tested it for LAN, so far as I can remember). I was able to get the player count showing correctly, for my purposes at least, by making a small addition to the engine code. I’m still on UE4.10, so I can’t guarantee this will work for later engine versions, but I imagine it will.

In OnlineSessionAsyncLobbySteam.cpp
I added the lines below to the implementation of the function FillSessionFromLobbyData

const int32 LobbyMemberCount = SteamMatchmakingPtr->GetNumLobbyMembers(LobbyId);
Session.NumOpenPublicConnections = Session.SessionSettings.NumPublicConnections – LobbyMemberCount;

I inserted these lines at line 350, although this might be different for different engine versions for all I know, so just make sure you’re in FillSessionFromLobbyData right after the for loop.

That doesn’t take into account private connections, but my game doesn’t use private connections, and the GetNumLobbyMembers function does always seem to accurately reflect the total number of players in the session.

Anyway, I added this to my game about a year ago now, and it seems to have worked since. I hope it does for you too, but I don’t know how watertight the solution is.

Best of luck,

Hi Jonwood, thanks for the reply, I’m not building the game from source so I don’t have access to the engine code for this project, but that seems like a reasonable way to fix it. Still I’ll come back after I find a way to fix this issue. I have to make sure I’m suing the OnlineSubsystemNull even when Steam is connected to avoid this issue. I’ll mark this as the answer for now :slight_smile:

We encountered the same issue. Seems the STEAMKEY_NUMOPENPUBLICCONNECTIONS key is never updated.

In Session.NumOpenPublicConnections = FCString::Atoi(ANSI_TO_TCHAR(Value)); just forever gets the default value.

Only after a player joined, the player calculates it again, this time with:

Session.NumOpenPublicConnections = MaxLobbyMembers - LobbyMemberCount;

There is code (FOnlineAsyncTaskSteamUpdateLobby) that looks like it should update NumOpenPublicConnections, but it’s never called:

UE_LOG_ONLINE(Verbose, TEXT("Updating Lobby Data (%s, %s)"), *It.Key(), *It.Value());
if (!SteamMatchmakingPtr->SetLobbyData(SessionInfo->SessionId, TCHAR_TO_UTF8(*It.Key()), TCHAR_TO_UTF8(*It.Value())))

If you decide to call it, it just destroyed the entire session and nobody can ever join it again.

Epic decided to delete all steam keys, but instead of deleting them with DeleteLobbyData, they just change it to ‘’

UE_LOG_ONLINE(Verbose, TEXT("Removing Lobby Data (%s, %s)"), *It.Key(), *It.Value());
if (!SteamMatchmakingPtr->SetLobbyData(SessionInfo->SessionId, TCHAR_TO_UTF8(*It.Key()), ""))

And even if the update would work, it never updates NumOpenPublicConnections.


In conclusion, you have to call the update settings manually, even though no settings change.

sessionInterface->UpdateSession(sessionName, Session->SessionSettings);

Then put the update of NumOpenPublicConnections into the update of the settings.

int32 LobbyMemberCount = SteamMatchmakingPtr->GetNumLobbyMembers(SessionInfo->SessionId);
int32 MaxLobbyMembers = SteamMatchmakingPtr->GetLobbyMemberLimit(SessionInfo->SessionId);
Session->NumOpenPublicConnections = MaxLobbyMembers - LobbyMemberCount;

And also set the bLobbyJoinable to true by removing bAllowJoinInProgress to keep the session ‘alive’


Or just leave the value wrong in steam, and overwrite it locally on every player who looks at it, like Jonwood explained

Hey, sorry but where exactly are we suppose to call this from?
sessionInterface->UpdateSession(sessionName, Session->SessionSettings);

We called it whenever we change anything on the session, AddPlayer, RemovePlayer, AddToList, RemoveFromList, StartSession, EndSession, etc pp.

Thanks for the reply! I’m not new to c++ or unreal but I’m very new to steam integration and I’m not too sure what you mean still. Is there any reason Jonwood’s solution wouldn’t work? It seems simpler. Anyways, if you’d like to add be in discord that would be tremendously helpful. Discord: Blindopoly#1003

My problem is that SteamMatchmakingPtr->GetNumLobbyMembers always just returns 1 after the game is started, even if there is more than 1 person in the game.

1 Like