The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Joining and Re-joining Lobbies

2020-04-10 04:07:36


I am having a hard time with the following flow...

  1. I join a lobby with PhotonNetwork.JoinLobby()
  2. PhotonNetwork.InLobby is "true". All good here.
  3. I join a room (with either CreateRoom() or JoinRoom())
  4. PhotonNetwork.InLobby is "false". I don't know whether this is intended behavior or not... but it's fine. (I'm not sure why joining a room bumps you from a lobby)
  5. I leave the room with PhotonNetwork.LeaveRoom();
  6. I try to join a lobby again, with PhotonNetwork.JoinLobby()

Step 6 above does not seem to work. I can't seem to join a lobby again. It won't fire "OnJoinedLobby" and PhotonNetwork.InLobby continues to be false.

Whats going on here? Is this supposed to work this way?


2020-04-10 10:35:26

Hi @Brant,

Thank you for choosing Photon!

  1. that's expected yes. You can be either in a lobby or in a room or neither. You can't be joined to both at the same time, in fact you need to be on completely different servers for that matter.
  2. when do you try to join a lobby again? after / in which callback? make sure to do it inside or after OnConnectedToMaster.

2020-04-10 13:01:25

@JohnTube - Thanks or the response.

OnConnectedToMaster is called much earlier in the process of things. Before step #1 is when I do things like authenticate to the servers. In other words, by the time I get here, I connected to master several scenes ago.

Am I misunderstanding something? Would joining rooms/lobbies disconnect me from master?

To answer your question, I am currently just doing this in a bit of a test loop. It looks something like this (some of this is just pseudo code, just trying to show the flow):

2020-04-10 14:36:04

@JohnTube You pointed me on the right path! Thank you.

In re-reviewing documentation, I saw this bit:

Particularly, the part that reads: >When leaving a room, the LoadBalancingClient will disconnect the Game Server and connect to the Master Server. This wraps up multiple internal actions.

Wait for the callback OnConnectedToMaster, before you use lobbies and join or create rooms.

So, given the flow I outlined above, the corrected version would be:

Thanks again for the help!

Back to top