Can't reconnect after Timeout: ReconnectAndRejoin() failed.
Options
I am developing a multi-user VR experience. We are using PUN v2 in Unity and a Photon OnPremise server instance. For some reason we get very frequent timeouts and I can't find a way to reconnect and rejoin the room after a disconnection.
If I use the
If I try to connect normally, I am told that the Client is already connecting, or that the player is already in the room, or that the room is full, depending on the order of the callbacks.
As a sidenote,
Any pointer as to what could be going wrong would be very appreciated. Code snippet below:
If I use the
PhotonNetwork.ReconnectAndRejoin()
method I get this error:ReconnectAndRejoin() failed. It seems the client doesn't have any previous authentication token to re-connect.
If I try to connect normally, I am told that the Client is already connecting, or that the player is already in the room, or that the room is full, depending on the order of the callbacks.
As a sidenote,
NetworkClientState
always seems to return ConnectingToGameServer
.Any pointer as to what could be going wrong would be very appreciated. Code snippet below:
public override void OnConnectedToMaster() { Debug.Log("Joined Master..."); PhotonNetwork.JoinLobby(); } public override void OnJoinedLobby() { Debug.Log("Joined Lobby..."); RoomOptions options = new RoomOptions(); options.EmptyRoomTtl = 30000; options.PlayerTtl = 120000; options.MaxPlayers = 2; <del class="Delete"></del> PhotonNetwork.JoinOrCreateRoom("Default", options, TypedLobby.Default); } public override void OnJoinedRoom() { if (playerPrefab != null) PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity, 0); NetworkingSpawner spawner = FindObjectOfType<NetworkingSpawner>(); if (spawner != null) spawner.OnNetworkingStarted(); } public override void OnDisconnected(DisconnectCause cause) { Debug.LogWarning("Disconnect.." + cause); if (cause == DisconnectCause.ClientTimeout) PhotonNetwork.ReconnectAndRejoin(); } .... void Connect() { Debug.Log("Try connect..."); if (!PhotonNetwork.IsConnected) { PhotonNetwork.ConnectUsingSettings(); } }
0
Comments
-
Hi @meredityman,
Thank you for choosing Photon!
As you can read here on the list of main differences between Photon Cloud and Photon Server v4.0.29.11263:Ther server does not fully support quick rejoin feature (ReconnectAndRejoin) as it does not implement session tokens.
What you could do is:
- always cache the room name on the client.
- call Reconnect to recover from unexpected disconnect or just ConnectUsingSettings or another method you use to connect
- then once reconnected call RejoinRoom.0