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.

Return to lobby after leaving game

2017-07-21 12:55:53

I'm trying to figure out how to return to a lobby after leaving a game.
My understanding is that when you Join a room, you leave the lobby, leave the master server, and join a room on a game server. So when you leave that room, you are no longer in a lobby and you are connected to a game server so you can't call JoinLobby.
To return to the lobby do I have to disconnect from photon, reconnect, and join the lobby?

Thank you for your time.


2017-07-21 22:23:36

Hi @ScottS,

When you leave the room you automatically disconnect from the Game Server and connect to the Master Server.
If you enabled auto join lobby then you will be joined to the lobby.

2017-07-22 05:11:41

Thank you for your help!
When OnLeftRoom() is called, I am not yet on the master server. So I start a coroutine like this:

while (PhotonNetwork.Server != ServerConnection.MasterServer || PhotonNetwork.connectionStateDetailed != ClientState.ConnectedToMaster) {  
    yield return null;  

Which gets the job done, but I'm wondering if there is some other callback that I can use? OnConnectedToMaster() isn't called when leaving a room.

2017-07-22 10:48:02

If you enable "Auto Join Lobby" then
OnJoinedLobby will be triggered instead of OnConnectedToMaster
Otherwise, if "Auto Join Lobby" is disabled
OnConnectedToMaster is connected.

So you do not need the coroutine in OnLeftRoom to manually rejoin lobby.
Just wait for OnJoinedLobby.

2017-07-24 01:33:32

I believe I need to have AutoJoinLobby off so I can join a specific lobby. (We're leaning towards using a SQL lobby) When you LeaveRoom you're technically going back to master but OnConnectedToMaster isn't called. Assuming you have AutoJoinLobby off, is there any way to determine when you've returned to the master server so you can join a lobby again?

2017-07-24 09:45:55

Maybe you are switching scenes and the callback call is lost during the transition.
Can you try implement all connection callbacks from IPunCallbacks (just get the signature from there and add methods to a MonoBehaviour in the scene or implement interface if you want)

2023-03-27 20:47:43

Hello JohnTube and all the other programmers :),

I wanted to ask you how to implement (maybe via script) automatic connection to the lobby instead of the master server? I didn't find a solution for this problem and I am very new to photon...

I hope for a answer soon :)



I found my problem! I tried to join a lobby after Leaving a room immediately (in the "OnLeftRoom"-method). That is a mistake because the client didn't even made it to the point to connect to the master server again. So I had to write the "JoinLobby"-method in the "OnConnectedToMaster"-method. I think that can happen often, if people try to connect their game to the server in one scene and join a lobby in another...

I hope I can help some other lost soul. Have a nice week from germany :),


Back to top