Failed to join Session

Hi Folks,
I’m facing a multiplayer issue I hope you can help me with.
In short:

I’m running the game with these multiplayer options:

  • Number Of Players: 2
  • Run Dedicated Server: false

The project is set to use OnlineSubsystemNull.

On the first player, I create a Session with name MySession with these configurations

SessionSettings->bIsLANMatch = true;
SessionSettings->bUsesPresence = true;
SessionSettings->NumPublicConnections = 8;
SessionSettings->NumPrivateConnections = 0;
SessionSettings->bAllowInvites = true;
SessionSettings->bAllowJoinInProgress = true;
SessionSettings->bShouldAdvertise = true;
SessionSettings->bAllowJoinViaPresence = true;
SessionSettings->bAllowJoinViaPresenceFriendsOnly = false;

On the second player, I join the same session but, obviously, without creating it again.

The session is correctly created for the first player, but the problem is that when I try to join the same Session with the second player, I keep getting this error and I’m not able to join:

LogOnline:Warning: NULL: Session (MySession) already exists, can't join twice

Without posting any big code here, I assure you that the code for creating the session is not being called on the second player.

I suspect the issue is caused by calling the Create and Join Session passing the same UniqueNetId using

GetFirstGamePlayer()->GetPreferredUniqueNetId()

but if that’s the case, how can I test my application on the same machine using two different players?

Many thanks in advance for any feedback guys.

Hey AndreaCammarata,

The warning you are getting isn’t so much because you want to test two players, its that the player you are trying to join the session with is already either hosting a session or is already in a session.

As a rule, the JoinSession function makes sure that the Player follows this:

"Don't join a session if already in one or hosting one"

I can suggest that you make sure one player is hosting the game and the other is joining but only one host and one join.

Also, as a side note, I know you are using the OnlineSubsystemNULL but, if you plan on going to Steam, you will run into some issues trying to use two players on one Steam account and will need a secondary computer to test with. This issue however should be limited to Steam only.

Thanks for your answer. I’ve made some more tests and I was perfetly able to connect two players using the Steam Online Subsystem with two accounts on two different machines.

However, for testing purpose, I should be able to test multiplayer functionalities on the same machine and, ideally, starting the game with Multiplayer Options → Number of Players set to 2.

I saw several example projects working in that way (such as the MultiplayerShootout or Shooter Game) so I’m just wondering what I’m doing wrong here.

Any thoughts?

Hey ,

When you use the Multiplayer Options to set a number of characters, when you launch the game in the editor, those characters are going to automatically join either the dedicated server (if you have it checked) or, one will be host and the other will be client. If you are trying to use the JoinSession after this point, it makes sense that you will get the error as both characters are already in a session.

Hey, yes, your answer perfectly makes sense now. My big mistake was thinking that users were able to create and join multiple sessions with different names, but I was obviously wrong. Thanks for your help and time, I really appreciated it.

No problem. If you need more help regarding this issue, feel free to reply to this thread.

Worked for me when calls “Destroy session” on client before leave map.

2 Likes

Solved an issue I had when when clients would leave or be kicked they couldn’t rejoin or reconnect. I needed to call destroy session before trying again! Thanks!

If you are opening a new level, try adding “?listen” to the options. Fixed the issue for me in blueprints