Photon: I call PhotonNetwork.LeaveRoom() but my character doesn't leave

edit: this could be an issue in another script I’m using

I’m using PUN (free version).

After LeaveRoom() is called, all the players and player owned objects get destroyed as expected, but

OnLeftRoom() callback never gets called, and as a result, the player is stuck in the scene.

The script does something like this (and the class inherits from Photon.PunBehaviour):

public void leaveRoom() {

public void OnLeftRoom() {
    print("loading level");

The bug only occurs when there’s two players in the room.

update: it seems we attempt to connect to master after d/c but it never succeeds and photon does not throw any errors

This was the output from the NetworkingPeer.DebugReturn(...) member method.

Resending: CMD(5 c#:255 r/u: 67/0 st/r#/rt:68313/1/78313). times out after: 56 sent: 68313 now: 68375 rtt/var: 24/8 last recv: 16
NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/StoreAssets/Photon/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1530)
PhotonHandler:Update() (at Assets/StoreAssets/Photon/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:177)

I found a work around that “solves” this. Instead of leaving the room then waiting for the OnLeftRoom callback, I call PhotonNetwork.Disconnect() then load level on the following line. This sometimes causes the player to load from in game → main menu → in game.

To fix this, I created a DontDestroyOnLoad object which will make the player load the appropriate scene and knows when the player should be in the main menu.