LeaveRoom and Disconnect issues - Unable to reconnect and timeout disconnect

Hi,

For my game, I have a main menu scene which calls connectusingsettings on load.
after joining a room, i load my game scene using LoadLevel.
In this game scene, i have a button called disconnect which brings the player out of the game scene and back to the main menu scene.
After I use LeaveRoom, I transition to the main menu scene in the OnLeftRoom function.
The problem is after I transition to the main menu scene, I see the following lines of log from the console and subsequently, i get timeout disconnect.
OpSetPropertiesOfRoom()
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2130)
Photon.Realtime.LoadBalancingPeer:OpSetPropertiesOfRoom(Hashtable, Hashtable, WebFlags) (at Assets/Photon/PhotonRealtime/Code/LoadbalancingPeer.cs:695)
Photon.Realtime.Room:SetCustomProperties(Hashtable, Hashtable, WebFlags) (at Assets/Photon/PhotonRealtime/Code/Room.cs:385)
Photon.Pun.PhotonNetwork:SetLevelInPropsIfSynced(Object) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2043)
Photon.Pun.PhotonNetwork:NewSceneLoaded() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1341)
Photon.Pun.<>c:<Start>b__13_0(Scene, LoadSceneMode) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:125)
UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)
Resending: CMD(5 ch#/sq#/usq#: 255/6/0 r#/st/tt:1/8144/18144). times out after: 309 sent: 8144 now: 8514 rtt/var: 89/55 last recv: 1150
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2130)
ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:808)
ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1555)
Photon.Pun.PhotonHandler:LateUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:170)
Timeout-disconnect! Command: CMD(5 ch#/sq#/usq#: 255/6/0 r#/st/tt:7/13580/18144) now: 18546 challenge: 3dcce11b
UnityEngine.Debug:LogWarning(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2126)
ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:775)
ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1555)
Photon.Pun.PhotonHandler:LateUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:170)

I have even tried to disconnect from the server entirely but I will still get the similar lines of debug statements.
What does this mean?

This is my disconnect functions
public void DisconnectPlayer()
    {
        Destroy(PhotonRoom.photonRoom.gameObject);
        //StartCoroutine(DisconnectAndLoad());
        PhotonNetwork.LeaveRoom();
    }

    public override void OnLeftRoom()
    {
        base.OnLeftRoom();
        //StartCoroutine(DisconnectAndLoad());
        sceneFader.FadeTo(MultiplayerSettings.multiplayerSettings.menuScene);
    }

Best Answer

  • Accepted Answer
    Hi @JohnTube,

    I found out the issue!
    It appears that if I change the timescale in order to 'pause' the screen, the leave room function would not be in effect.
    i appreciate your time and help going through my questions so much.
    You helped to explain a few foreign concepts to me as well. Thanks!

    I hope you have a great day and once again, thanks!

Answers

  • Please note that after I load the Main Menu, if I try to join random, I get the following lines of error.

    JoinRandomRoom failed. Client is on GameServer (must be Master Server for matchmaking) but not ready for operations (State: Leaving). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
    UnityEngine.Debug:LogError(Object)
    Photon.Pun.PhotonNetwork:JoinRandomRoom(Hashtable, Byte, MatchmakingMode, TypedLobby, String, String[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1588)
    Photon.Pun.PhotonNetwork:JoinRandomRoom() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1522)
    PhotonLobby:OnJoinButtonClicked() (at Assets/Scripts/Photon/PhotonLobby.cs:60)
    UnityEngine.EventSystems.EventSystem:Update()
  • Hi @studentttt,

    Thank you for choosing Photon!

    1. What platform is this? does this happen in the Unity Editor on also in a build? What Unity version? What PUN version?
    2. It looks like you don't wait until the client is ready to join rooms.
    After I use LeaveRoom, I transition to the main menu scene in the OnLeftRoom function.
    Delay loading main menu scene to OnConnectedToMaster after leaving a room. In OnLeftRoom the client is not ready yet to join other rooms.
  • hi @JohnTube,

    Thanks for replying.
    1. This is in Unity. It happens in both Unity Editor and also in build. For my project, I am using Unity 2018.4.4f1. I'm currently using Pun 2.16, Photon lib: 4.1.2.19.
    2. When I tried to do this on the Photon Demo, it works fine and I am able to join a room almost instantly after disconnecting. In my case, after the Disconnect function, it takes a long while before I am able to rejoin a room. I'm confused as to why this happens.

    I realised that the reason why I switch scene quickly was due to another function, and I have removed that function.
    Following which, I have taken your suggestion of loading the main menu scene to OnConnectedToMaster, but the function is never called and the following lines of debug statement can be seen.
    Resending: CMD(5 ch#/sq#/usq#: 255/7/0 r#/st/tt:1/8728/18728). times out after: 41 sent: 8728 now: 8794 rtt/var: 17/6 last recv: 183
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2130)
    ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:808)
    ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1555)
    Photon.Pun.PhotonHandler:LateUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:170)
    Timeout-disconnect! Command: CMD(5 ch#/sq#/usq#: 255/7/0 r#/st/tt:8/10287/18728) now: 11613 challenge: 1ee682c9
    UnityEngine.Debug:LogWarning(Object)
    Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2126)
    ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:775)
    ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1555)
    Photon.Pun.PhotonHandler:LateUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:170)

    I used the following lines of code.
        public void DisconnectPlayer()
        {
            Destroy(PhotonRoom.photonRoom.gameObject);
            PhotonNetwork.LeaveRoom();
        }
    
        public override void OnConnectedToMaster()
        {
            base.OnConnectedToMaster();
            SceneManager.LoadScene(MultiplayerSettings.multiplayerSettings.menuScene);
        }
    
  • Hi @studentttt,

    Use PhotonNetwork.LoadLevel from master client instead of SceneManager.LoadScene.
    Otherwise, you need to do this: "PhotonNetwork.IsMessageQueueRunning = false;" before starting scene load manually.
    Read this and this.
  • Hi @JohnTube,

    I have noted on the LoadLevel.
    However, my issue on not being able to leave the run persists as OnConnectToMaster is never called.
    Does this mean that there was an issue leaving the room?
  • Accepted Answer
    Hi @JohnTube,

    I found out the issue!
    It appears that if I change the timescale in order to 'pause' the screen, the leave room function would not be in effect.
    i appreciate your time and help going through my questions so much.
    You helped to explain a few foreign concepts to me as well. Thanks!

    I hope you have a great day and once again, thanks!
  • Hi @studentttt,

    My pleasure.

    Read this about timescale.
Sign In or Register to comment.