JoinRandomRoom fails if called "too early" after CreateRoom

Options
Hi,


I'm trying to implement a "quick play" feature in my game. It should setup a match without showing the room list to the user, just pair it with other "quick play" players and start the game ASAP.
My implementation, as suggested in the docs, is try joining a random room and if that falis then create a new room and wait for players.

A problem arises when first player creates the room and second players tries to JoinRandomRoom shortly after (by shortly I mean 10 or 20 seconds). Second players receives an OnPhotonRandomJoinFailed, so it creates its own room and both players lock waiting each other.

I've noted that if I wait a lot more before calling OnJoinRandomRoom (maybe 50 or 60 seconds) the problem disappears and OnJoinedRoom is called in the second player as expected.


Setup:

- Two test machines running Windows 10, connected directly via ethernet cable and properly configured with static ips in the same network and with both firewall and antivirus disabled.

- Local Photon Server 4.0.28.2962 installed and running in one of the machines.

- Tried running two instances of my game in the machine where Photon Server is running with the same result.

- Also tried with autoJoinLobby activated and deactivated. In the first case I call JoinRandomRoom from OnReceivedRoomListUpdate. In the other case I call it from OnConnectedToMaster. It doesn't make any difference.

- The room is created with following properties:

       RoomOptions ro = new RoomOptions()
       {
            MaxPlayers = playersPerRoom,
            IsVisible = true,
            IsOpen = true,
            CustomRoomProperties = customProperties,
            CustomRoomPropertiesForLobby = null,
            CleanupCacheOnLeave = true,
        };
        PhotonNetwork.CreateRoom(null, ro, null);

My thougts are that one of theese is causing the problem:

1 - Photon Server needs some time between it receives a CreateRoom petition and the moment it can "show" it to the incoming JoinRandomRoom requests. If this is correct, I wonder why Photon Server needs this extra time and why it is soooo long (50 or 60 seconds!).

2 - PUN doesn't send JoinRandomRoom requests to Photon Server and instead, it looks for available rooms in the local room list. If this is correct (maybe for bandwidth saving reasons), how can I be sure that I my local room list is synchronized with the server's room list before calling JoinRandomRoom?

In both cases I can't think of a safe and robust solution for my "quick play" feature. I can't control when players enter the quick play mode and even in the simplest case with only two players, the risk of interlock is present.


Thank you.

Comments

  • Hi @FrSrz,

    In your RoomOptions setup I guess the playersPerRoom is larger than 1, isn't it? Besides that the settings looks okay and shouldn't prevent from finding the game. When the second client uses PhotonNetwork.JoinRandomRoom() I guess you use the function without parameters, means that you don't apply or add any kind of filter options, do you? Unless you have any filter options this shouldn't prevent joining another game either.

    1 - [...]


    I can't imagine that this is a problem, but maybe I'm wrong. Can you please check what happens if you change the PhotonServerSettings in order to use the Photon Cloud? It would be interesting to see, if this results in the same behaviour.

    2 - [...]


    When you are connected to Photon, you will receive a room list for the first time. To check if you receive the room list, you can implement OnReceivedRoomListUpdate callback. Afterwards you can use PhotonNetwork.GetRoomList() and see, if it contains open rooms.