ReturnCode: 32748 (User does not exist in this game)

Options
Hello! :)

Right now I'm working on reconnecting players to games after disconnecting.
It works perfectly fine if the player doesn't close the application, but after closing and reopening the application I get the error Operation failed: OperationResponse 226: ReturnCode: 32748 (User does not exist in this game). on PhotonNetwork.ReJoinRoom(roomName).

I define a PhotonPlayer.UserId which is given to the player before they connect to a room (in lobby). If the player disconnects from photon while playing, I store Room name and UserId in PlayerPrefs and save it before the game exits.
When they start up the game again, they join a lobby like normal (PhotonNetwork.ConnectUsingSettings(settings)) and the player can then choose to rejoin the game. In that case I do:
PhotonNetwork.player.UserId = PhotonUserId;
PhotonNetwork.ReJoinRoom(RoomName);


And then get the previously mentioned error.
As mentioned reconnecting works fine if the player doesn't close the application before rejoining through the exact same method as I just mentioned. :)

Would love some help from someone who can tell me what I'm doing wrong. :D

Cheers!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Skegon,

    It looks like RoomOptions.PlayerTtl is not long enough to allow rejoin.
    There is PhotonNetwork.ReconnectAndRejoin() to recover from unexpected disconnects.
  • Skegon
    Options
    RoomOptions.PlayerTtl is plenty long. :) As mentioned normal reconnects works fine. Ttl is 10min, so that is not a problem.

    I was looking at ReconnectAndReJoin, but it doesn't allow me to use settings like ConnectUsingSettings. Also I'm not sure reconnect works if I have closed the application?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Are you keeping the same UserId before leaving and before trying to rejoin?
  • Skegon
    Options
    Yes I define the UserId when joining first and then the player will have the same UserId when rejoining.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2019
    Options
    Double check this as the error 32748 means that there is no inactive actor inside the room's actors' list with the same UserId as the one rejoining.
    So either the UserId is different or the actor was never inactive (PlayerTTL == 0) or the inactive actor was removed from the room because the PlayerTTL expired (-1 never expires).
  • Skegon
    Options
    I'll double check tomorrow that the character is indeed inactive. I have been doing nothing but checking the UserId, as I thought that was the primary issue, but it is identical. PlayerTtl is set to 10 * 60 * 1000 for ten minutes, but I will try with -1, although I am sure this isn't the issue as players are still able to connect just fine if they don't close the application. :)
  • Skegon
    Skegon
    edited June 2019
    Options
    So I have been testing around, making sure everything is set correctly, and it turns out that PhotonNetwork.player.UserId = PhotonUserId; doesn't actually set the UserId of the player. Which is why when I don't close the application, the photon-defined UserId is still the same, which means I can rejoin, but after I close the application the UserId will differ, and even if I set it, it doesn't actually update.
    Do I need to do anything in particular in order to actually update the PhotonPlayer? Because just setting the UserId in this fashion doesn't seem to be enough.
  • Skegon
    Skegon
    edited June 2019
    Options
    Aha, seems like UserId is set in a completely different fashion.
    Setting UserIDs
    Once authenticated, a Photon client will keep the same UserID until disconnected. The UserID for a client can be set in three ways:

    Client sends its UserID before connecting by setting AuthenticationValues.UserId. This option is useful when you do not use Custom Authentication and want to set a UserID.
    An external authentication provider returns the UserID on successful authentication. See Custom Authentication. It will override any value sent by the client.
    Photon Server will assign GUIDs as IDs for users that did not get UserIDs using 1 or 2. So even anonymous users will have UserIDs.


    If that is the case, do you know what the UserId setter's purpose is then? For local play?
  • Skegon
    Options
    So yeah, that was indeed my issue. Not setting UserId through AuthenticationValues.