PUN Reconnect throws an error

Hi

The master client creates a room.
RoomOptions roomOptions = new RoomOptions() { MaxPlayers = 10, PublishUserId = true };
PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);

The other clients join the master client.
bool isAvailable = PhotonNetwork.JoinRoom(roomName);

The clients can leave the room by clicking the "Exit" Button.
PhotonNetwork.Disconnect();
PhotonNetwork.LoadLevel("Offline Scene Name");

Once disconnected, I can't reconnect again!
This is the error:
- Client Side
JoinRoom failed. The client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.
- Server Side
No Error

I think this happened when the client has not joined the Lobby.
Actually, the "GetRoomList" function returns null even if the server is still alive.

Please help me to solve this issue!

Best Answer

  • JohnTube
    JohnTube ✭✭✭✭✭
    Answer ✓
    Hi @sweetmei25,

    Thank you for choosing Photon!

    bool isAvailable = PhotonNetwork.JoinRoom(roomName);

    You do know that Photon operations are asynchronous and calling JoinRoom does not mean you are instantly joined to the room. JoinRoom returns if the client succeeded to add the room join command to the queue of commands to send to the server and nothing more.
    You need to wait until the success or failure callback is triggered to know the outcome of the room creation request.

    The clients can leave the room by clicking the "Exit" Button.
    PhotonNetwork.Disconnect();
    PhotonNetwork.LoadLevel("Offline Scene Name");

    Call LeaveRoom() instead of Disconnect(); and maybe move the load level call inside the room left callback.

    Actually, the "GetRoomList" function returns null even if the server is still alive.
    You can't get rooms list while joined to a room, you need to be joined to a lobby for that.

    - Server Side
    No Error
    What do you mean server side? do you self-host Photon Server?

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Answer ✓
    Hi @sweetmei25,

    Thank you for choosing Photon!

    bool isAvailable = PhotonNetwork.JoinRoom(roomName);

    You do know that Photon operations are asynchronous and calling JoinRoom does not mean you are instantly joined to the room. JoinRoom returns if the client succeeded to add the room join command to the queue of commands to send to the server and nothing more.
    You need to wait until the success or failure callback is triggered to know the outcome of the room creation request.

    The clients can leave the room by clicking the "Exit" Button.
    PhotonNetwork.Disconnect();
    PhotonNetwork.LoadLevel("Offline Scene Name");

    Call LeaveRoom() instead of Disconnect(); and maybe move the load level call inside the room left callback.

    Actually, the "GetRoomList" function returns null even if the server is still alive.
    You can't get rooms list while joined to a room, you need to be joined to a lobby for that.

    - Server Side
    No Error
    What do you mean server side? do you self-host Photon Server?
  • Call LeaveRoom() instead of Disconnect(); and maybe move the load level call inside the room left callback.

    Actually, the "GetRoomList" function returns null even if the server is still alive.
    You can't get rooms list while joined to a room, you need to be joined to a lobby for that.


    Thanks for your kindly answers. :)

    - Server Side
    No Error

    Server Side : my mistake, this means master client, the master client creates the room

    I will try and get to back to you!

    Thanks. Much appreciated!