Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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;
Product Version: UE 4.16
more ▼

asked Jul 24 '17 at 11:06 PM in C++ Programming

avatar image

361 16 17 25

avatar image Jonwood Aug 30 '17 at 08:23 PM

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.

avatar image swfly Sep 02 '17 at 04:08 PM

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!

avatar image Jonwood Sep 02 '17 at 07:54 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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, Jon

more ▼

answered Sep 02 '17 at 08:00 PM

avatar image

83 2 8 16

avatar image virtual_nomak Nov 10 '17 at 11:16 AM

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 :)

avatar image ellocator Nov 30 '18 at 12:03 PM

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()), ""))
avatar image ellocator Nov 30 '18 at 01:46 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question