Search Unity

Help Wanted Photon: joining after disconnect fails (not rejoining)

Discussion in 'Multiplayer' started by Olipool, Oct 31, 2020.

  1. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    155
    Hi all,

    I get the following error with Photon:
    SupportLogger OnJoinRoomFailed(32749,Found inactive UserId 'ccbb03dc-5d05-45b7-a90b-14dd172d524f', but not rejoining (JoinMode=0).).

    The scenario is like this:
    I connect to the master server and receive a room list and populate my UI with the rooms. It is empty. I create a room, the list gets updated and I join. After that I disconnect using LeaveRoom as well as Disconnect().
    I then connect once again like before, I get the room list and my room is still there but I can't join it because of the error above.

    What would be the best way to deal with that? I could store the last joined room name somewhere and if I want to join the same room as before I could try RejoinRoom instead of JoinRoom but is this a valid approach? It seems to work fine but what if a player make "room hopping"? Joining room1 then room2 and then room1 again? This leads to normal JoinRoom but only works when the player has timed out.
    And what if the room he disconnected is still there but the player is timed out, Rejoin would not work because that is giving me an "User does not exist in this game".

    So I guess what I need is something like IsPlayerActiveInRoom or something like that.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,691
    When the room sets a PlayerTTL, players become inactive if their connection fails. The remaining players will get notified about that user becoming inactive. During the PlayerTTL time, a player can Rejoin a room but not Join it. The Rejoin gets the same ActorNumber as before for this player. A Join would add one more player to the room (and let the old one time out).

    To make sure the server does what you expect, Join and Rejoin are different actions.
    So what you want is a Rejoin.
     
  3. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    155
    Thank you as always for your support :)
    My problem is how do I know if the player is inactive in THIS room so I can choose Rejoin or if he is timed out so I have to use Join? Because like I said using Rejoin gives me "User does not exist in this game".

    One other quirk I am trying to understand: I have buttons to leave a room and to disconnect completely. If I leave a room then I am no longer in it and have to Join. If I just disconnect, I can Rejoin. All very clear so far.
    But my button for disconnect checks if I am still in a room and I am calling LeaveRoom(false) explicitly before Disconnect(), so a player who presses the button explicitly will also leave the room. But somehow I stay in the room inactive. Is this an intended behavior or do I have to check my code again? I debugged it and saw LeaveRoom(false) then Disconnect() and then Join did not work but Rejoin.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,691
    You can try a rejoin and if that fails, you can do something else.
    The workflow is meant to recover from a connection loss, so there should always just be one room you could ReconnectAndRejoin to (this is actually the faster way to get back into a room you dropped out).

    When you call an operation, it gets queued locally, until our code wraps up messages and sends a datagram. This aggregates messages in less datagrams.
    Disconnect will drop anything that is in the out queues, enqueue a single disconnect message and send it right away. This makes sure the disconnect is processed quick.

    A disconnect is supposed to mean the client will no longer send or reply to messages, so from that moment on, the communication can no longer be reliable.

    On the other hand, this means your leave gets dropped, unless it's already sent.
     
  5. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    155
    Thanks, that explains the observed behavior perfectly and makes very much sense.

    I am using ReconnectAndRejoin in case of an unintentional disconnect. But when the player presses the Disconnect button explicitly I just use Join when he connects again and chooses a room. But in some cases, he is still in the room he disconnected from.

    My suggestion would be, that Disconnect could also get a parameter like LeaveRoom(bool becomeInactive), so if the player Disconnects on purpose I can call Disconnect(false), and the player gets removed from the room he is in as well.
     
unityunity