Users do not see the same number players in a room, iOS


I am running the same code on two computers. Both of them are connected on the network, and the Logs are ON.

In both computers I see that both users are connected/joined to the same room, but one player finds only one player in the room, and the other player finds two players. Could this be because the first player firstly connects to another room, before it connects to that room?

I am looking forward to your feedback.

Thank you


  • Hi @Vasilis.

    I need more information on this issue.

    How are you making sure that they are indeed both in the same room?

    See for potential reasons why they could end up in different rooms.

    Has one of the players previously disconnected without properly leaving the room (i.e. by stopping the app through the debugger)? In that case he might not have timed out yet, so the other player still sees it for a few seconds, when joining that room.

    The disconnected player then might be joining a different room, after he connected again.

  • Hi @Kaiserludi,

    thank you for your quick response. I see in the logs that both players are connected to the same room.

    Before I connect to a room, I call the method

    -(void)leaveRoomComeBack:(BOOL)comeBack withResponce:(void (^)(BOOL status))leaveRoomReponse

    Here, comeBack is YES

    If the status is YES, I call the method

    [mLoadBalancingClient opJoinOrCreateRoom:roomName];

  • Hi @Vasilis.

    I see in the logs that both players are connected to the same room.

    Sorry, but that's still too unspecific.

    How do you make sure that they actually are inside the same room and your logging code doesn't just think that they are?

    As outlined in the doc that I have linked in my previous response, it is perfectly possible that i.e. they are inside different rooms that just have the same room name, but are in different cloud regions.

    "leaveRoomComeBack" is not part of the Photon APIs nor of a Photon demo project, so I assume that this is part of your own code base. This means I can't know for sure if it works as intended and does what it name indicates.

    However if you want to be sure that you join an existing room and don't accidentally create a new one, then you should call opJoinOrCreateRoom(), but rather opJoinRoom().

    In the situation that your client unintentionally connects to a different region or uses a different appID or appVersion than with its previous connect, opJoinRoom() will fail with an error message saying that the room doesn't exist, while opJoinOrCreateRoom() will silently create a new room with the same name.

    Accidentally connecting to a different region can easily happen when you connect to the region with the best ping in both connects and the pings from your location two the best and second best region are very close to each other, as ping-times naturally fluctuate a bit, so which region is determined as the best one might vary between two connects.

    Also one region might become unreachable for a short period of time, i.e. due to a DDOS-attack on it's master server.

    The recommend approach to avoid such issues is to store the best region result in a file and to only connent with RegionMode::BEST if you don't have any region in file storage yet or if the player explicitly asks your app through the UI to redetermine which region the client has the best ping to, otherwise connect to the stored region with RegionMode::SELECT. This also greatly improves connection times for subsequent connects, as the time-intensive pinging procedure can be skipped for all connects but the initial one.

  • Vasilis
    edited December 2021

    Hi @Kaiserludi

    The region is fixed to eu.

    Both players are connected to the same room, because one of them sees the other.

    Assume that I have players A and B. They are both in room C.

    Suddenly, B disconnects, e.g. put the app in the background. When B is again online, I connect him to room D, and then to room C.

    When we is connected to room C, in the logs of player A, I see that player B has joined room C. But, in the logs of player A, I see that room C has only one player.

    Any idea why this is happening? Could it be because I switch from room D to room C too fast. This switch happens after I have received the event that the user has connected to room D

  • I modified my code, so that I no longer connect player B to room D. After, I reconnect him, I join him to room C.

    Player A sees that player B has joined the room C, but he does not receive any event from Player B, nor he can send any event to Player B

  • Hi @Vasilis.

    I have no explanation for this.

    Can you reproduce this with one of our demos?

    If yes, then please provide reproduction steps and I have look into what's going on.

    Otherwise please provide me with a minimal self-contained reproduction project.

  • Hi @Kaiserludi ,

    I found my bug. After I was reconnecting to the room, I was forgetting to reset the array that has the players. Thus, I was using the wrong number IDs.

    I apologize for the trouble!

    Thank you