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.

Photon not rejoining Master Server after leaving room

2018-04-23 05:28:32

Hi, I'm having an issue where Photon Network doesn't appear to rejoin the Master Server after leaving a room.

In our game, we switch between online and offline modes. This involves changing to a transition (loading) scene, which asynchronously loads the main scene, connects to photon if not connected and joins a room.

The scenario where it fails is when it is in the main scene in offline mode, we click a button to trigger reloading the scene in online mode which:

  1. Sets our own offlineMode bool to false.
  2. Calls PhotonNetwork.LeaveRoom().
  3. Loads the transition scene.
  4. In the Start method of a script in the transition scene, our ConnectToPhoton method is called.

The ConnectToPhoton method is as follows:

public void ConnectToPhoton() {  
      if (offlineMode) {  
                if (PhotonNetwork.connected) {  
                else {  
    else {  
         PhotonNetwork.offlineMode = false;  
     // If we are not connected to Photon, connect  
     if (!PhotonNetwork.connected) {  
     // Join the lobby if we haven't  
     else if (!PhotonNetwork.insideLobby) {  
     // Join a random room  
     else {  

Joining the offline room shows the following logs:

  • OnStatusChanged: Disconnect current State: Disconnecting
  • OnConnectedToMaster() was called by PUN. This client is now connected.
  • OnStatusChanged: Connect current State: ConnectingToGameserver
  • Joined a room: offline room // This is our own log which logs the room name when a room is joined

When the room is left in order to switch to an online room, only the method for the OnLeftRoom callback provides logs:

public override void OnLeftRoom() {  
            Debug.Log("OnLeftRoom() was called by PUN.");  

I am expecting either of the following methods to receive callbacks after the room is left:

        public override void OnConnectedToMaster() {  
            Debug.Log("OnConnectedToMaster() was called by PUN. This client is now connected.");  

        public override void OnJoinedLobby() {  
            Debug.Log("OnJoinedLobby was called by PUN. This client is now connected.");  

The client state of Photon at this point is 'ConnectedToGameserver', which according to the documentation means "Still in process to join/create room.(will-change)". Leaving it to process for a few minutes still does not trigger connecting to the master or joining the lobby.

I am not sure why Photon is not connecting to the Master Server after leaving the room, and appears to be still on the Game server. Any suggestions as to why it isn't, or what I might be doing wrong are appreciated.

In case it's useful, the Start method for our persistent (DoNotDestroyOnLoad) Network Manager script is:

void Start() {  
            PhotonNetwork.autoJoinLobby = true;  
            PhotonNetwork.automaticallySyncScene = false;  
            PhotonNetwork.logLevel = logLevel; // Currently set to PhotonLogLevel.Full, and set to ALL in the inspector  
            offlineMode = loadSceneOffline;  

I can provide more code blocks and logs if needed.


2018-07-12 06:44:34

Before connecting to master, photon connects lobby, so if you wanna connect to master, try like this.

public void OnJoinedLobby()

then call OnJoinedRoom();

2018-07-23 04:26:24

Thanks for the help jokerTM, I actually figured out the problem but forgot to post the solution.

I needed to add PhotonNetwork.ConnectUsingSettings(GAME_VERSION) to the clause where I was setting offlineMode to false, as Photon does not reconnect automatically when setting offlineMode to false, but PhotonNetwork.connected still returns true.

      // NOTE: Need to connect again when switching from offline to online  
      PhotonNetwork.offlineMode = false;  

This wasn't the case in a previous version of Photon, we had switched over to using Unity 2017 recently, which is when the issue started.

Thanks for the assistance though!

Back to top