I have had some problems with getting my server to advertise correctly. The problem is that if you start a session when the server isn’t a listen server the server will not advertise its existent. This is because in FOnlineSessionNull::NeedsToAdvertise the following code NullSubsystem->IsServer() will always return false if we are not already having a server.
This issue also exists in the shooter game example. During first 15 seconds “waiting for players” ironically it’s impossible to find the server on the lan. First after FOnlineSessionNull::StartSession is called FOnlineSessionNull::NeedsToAdvertise will be called again and this time we have started a listen server so it works. However with a game were join in progress should be disabled, players will never be able to find the server.
Assuming the shooter game example is using the online subsystem correctly, this isn’t working properly.
One solution would be to update the status after the level have changed, but that is a bit hacky. Since a session start probably always will be followed by a map change. I don’t understand why the create session method doesn’t also starts a listen server and changes the map. That would probably simplify the process a lot of setting up a session and using the online subsystem.
The issue might come from the fact that you are starting the online game before you actually travel and create the server. You could create the server and then start the session instead. This should avoid also voip issues which require a valid session in some cases.
That’s not how they do it in the shooter game which is my reference. Also I tried to start a listen server first. Then there are problems with not automatically registering the host as a player on the server.
I first create the session after a button in my GUI has been pressed by the user to make sure the game is fully initialized. Not sure if that was what you meant though.
So you start the game session from the main menu GUI when you have not yet setup a server, this might be the issue. If you create the server first and then start the session what do you get?
Yes, that’s because the FOnlineSessionNull::NeedsToAdvertise will return false when the session is created. First when the listen server is started after the map change and the warm-up is over, FOnlineSessionNull::StartSession is called and FOnlineSessionNull::NeedsToAdvertise will return true since it’s a listen server this time.
Then it’s advertising but the online session fails to register the host as a player on the server. Resulting in some warnings in the output log.
Provided that the shooter game example is using the IOnlineSession correctly, you shouldn’t need to create a listen server before the session is created. The problem is that it needs to start advertising after the map change.
Could you try to check if the bug persists in 4.5? I saw a commit that should fix it but I do not know if the change was merge into 4.5 or it will be in 4.6.
I just wanted to check on this issue and see if you are still having trouble with it. If it is working for you now, please post an answer explaining what resolved it for you, or let us know if you still need some help.
I’m sure it’s a horrible hack, but here’s one workaround: the IsServer() function that is used by FOnlineSessionNull::NeedsToAdvertise can be overriden by specifying a global delegate. Use something like
This will have the effect of making OnlineSubsystemNull (and everyone else) think that they are on server no matter what. Removing this delegate once the session is successfully started might be the right thing to do (-8