JoinOrCreateRoom failed. Client is on GameServer (must be Master Server for matchmaking) and ready.

Stack
MacOS Catalina 10.15.4
Unity 2020.1
PUN2 v2.22

I have a VR project running on Oculus Quest which was working till a few days ago. The user enters the lobby and chooses a room to connect.

Now suddenly, it works only in the editor but if I deploy on Oculus Quest, when I try to connect to the room I get this error code:
JoinOrCreateRoom failed. The client is on GameServer (must be Master Server for matchmaking) and ready. Wait for callback: OnJoinedLobby or OnConnectedToMaster.

This is the code I use for the connection
// JOIN ROOM
        public void JoinRoom (Room room) {
            Debug.Log ("[RoomService.cs]: Request to join Room ID:" + room.roomId);

            // check data integrity
            if (room == null) {
                Debug.LogError ("[RoomService.cs]:Impossible to connect to the room, no room data available");
                return;
            }
            _currentRoom = room;

            // keep track of the will to join a room, because when we come back from the game we will get a callback that we are connected, so we need to know what to do then
            isConnecting = true;

            // we check if we are connected or not, we join if we are , else we initiate the connection to the server.
            if (PhotonNetwork.IsConnected) {
                Debug.Log ("[RoomService.cs]: Client is connected, attempt to join/create room");
                RoomOptions roomOptions = new RoomOptions () { MaxPlayers = _currentRoom.maxPlayers, PublishUserId = true };
                PhotonNetwork.JoinOrCreateRoom (_currentRoom.roomId, roomOptions, TypedLobby.Default);
            } else {
                Debug.Log ("[RoomService.cs]: Client not connected...attempt to connect to Master Server");
                PhotonNetwork.ConnectUsingSettings ();
                PhotonNetwork.GameVersion = gameVersion;
            }
        }



 public override void OnConnectedToMaster () {
            Debug.Log ("[RoomService.cs]: Client Connected To Master Server :" + isConnecting);

            // we don't want to do anything if we are not attempting to join a room.
            // this case where isConnecting is false is typically when you lost or quit the game, when this level is loaded, OnConnectedToMaster will be called, in that case
            // we don't want to do anything.
            if (isConnecting) {
                RoomOptions roomOptions = new RoomOptions () { MaxPlayers = _currentRoom.maxPlayers, PublishUserId = true };
                PhotonNetwork.JoinOrCreateRoom (_currentRoom.roomId, roomOptions, TypedLobby.Default);
            }
        }

        public override void OnJoinedLobby () {
            Debug.Log ("[RoomService.cs]: Client Joined the Lobby:" + isConnecting);

            // we don't want to do anything if we are not attempting to join a room.
            // this case where isConnecting is false is typically when you lost or quit the game, when this level is loaded, OnConnectedToMaster will be called, in that case
            // we don't want to do anything.
            if (isConnecting) {
                RoomOptions roomOptions = new RoomOptions () { MaxPlayers = _currentRoom.maxPlayers, PublishUserId = true };
                PhotonNetwork.JoinOrCreateRoom (_currentRoom.roomId, roomOptions, TypedLobby.Default);
            }
        }

I don't get why is not giving any problem in the editor

Comments

  • Never mind, found the error. There was an error loading a scene but it was actually connecting to the room, so when I tried to connect to another room it couldn't switch
  • How can I solve this problem? I also encountered this problem recently, which caused me a headache.
  • Any tips would be greatly appreciated.
Sign In or Register to comment.