ReturnCode

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

Skegon
2019-06-19 12:10:42

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
2019-06-19 13:31:13

Hi @Skegon,

It looks like RoomOptions.PlayerTtl is not long enough to allow rejoin.
There is PhotonNetwork.ReconnectAndRejoin() to recover from unexpected disconnects.

Skegon
2019-06-19 13:49:40

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
2019-06-19 13:59:49

Are you keeping the same UserId before leaving and before trying to rejoin?

Skegon
2019-06-19 14:35:26

Yes I define the UserId when joining first and then the player will have the same UserId when rejoining.

JohnTube
2019-06-19 15:11:52

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
2019-06-19 18:26:22

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
2019-06-20 08:48:46

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
2019-06-20 08:58:34

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
2019-06-20 09:21:52

So yeah, that was indeed my issue. Not setting UserId through AuthenticationValues.

Back to top