Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Photon: joining after disconnect fails (not rejoining)

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

  1. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    320
    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:
    3,062
    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.
     
    elguncumayev likes this.
  3. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    320
    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:
    3,062
    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:
    320
    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.
     
  6. XSpitFire

    XSpitFire

    Joined:
    Jan 22, 2018
    Posts:
    15
    I have the same problem. Players leave the room to update game settings (graphics/audio../), but then they cannot re-join the same room they just left. They do not want to reconnect, but join as a fresh player.

    Are you suppose to call ReconnectAndRejoin first, and if that fails call JoinRoom ?
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    > Are you suppose to call ReconnectAndRejoin first, and if that fails call JoinRoom ?

    Yes.
    ReconnectAndRejoin will fail if the user isn't in the room anymore (after the PlayerTTL, the player gets removed instead of being inactive).
     
  8. mohdafzal20299

    mohdafzal20299

    Joined:
    Dec 1, 2020
    Posts:
    7
    Hi everyone,
    So when I am trying to join an already created room using JoinRoom(string). But I always get OnJoinRoomFailed - Game does not exist, errorCode - 32758. When I try to create this same room, I get these on OnCreateRoomFailed- errorCode - 32766, A game with the specified id already exist.
     

    Attached Files:

  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Both errors have to be expected. Why you get one and then the other is not clear but apparently possible to run into.
    Without an exact description of how you run this, it's not possible to help.
    Make use of our demos and docs to figure out a working path.