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! Your search result can be found below. Plus, we offer support via 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.

[Solved] Can't join room with the same "player.NickName"

LeonidB
2018-05-31 06:38:28

Hello guys! I'm facing some strange issue here.
After i updated my project to Unity 2018 and PUN 1.9, i'm facing some strange behaviour.
There is a logick in my project which sets the default player nickname to "Player".
I have 2 devices, default name is setted on both of them. Then i try to create room with one device and connect on other device, i see error:
Operation failed: OperationResponse 226: ReturnCode: 32746 (Join failed: UserId 'Player' already joined the specified game (JoinMode=0).). Parameters: {} Server: GameServer
BUT i dont set UserId anywhere. I'm only calling PhotonNetwork.player.NickName = "Player".
It seems that PUN does not generate random UserId for the session for some reason.
If i change PhotonNetwork.player.NickName = "Player1" on one of the devices, everything works ok.

And the second strange thing - before update (Unity 5.6.1 + PUN 1.85) the same code worked just fine and i have had no problems with connecting 2 players with the same nickname.

Could you please help me to solve this issue?
Thank you!

Comments

JohnTube
2018-05-31 09:21:26

Hi @LeonidB,

PhotonNetwork.player.NickName
Should not set the UserId. You are probably setting the UserId before connecting. Can you log the values for the UserId per player? Maybe look for all references to the PhotonPlayer.UserId in your code. Or maybe you are using Custom Authentication and returning same UserId value.
And the second strange thing - before update (Unity 5.6.1 + PUN 1.85) the same code worked just fine and i have had no problems with connecting 2 players with the same nickname.
Since PUN 1.88, by default, each player inside a room must have a unique UserId.
Changed: The room option "CheckUserOnJoin" is now always used. This means you have to use UserIDs to be able to rejoin a room. This was enabled before in most cases but now it's mandatory. If you don't set a userID, the server will assign a temp one for the "session".

LeonidB
2018-05-31 13:26:01

Hello @JohnTube!
Thank you very much! It seems, if UserId is not setted manually or through custom authentication system, its automatically set as = player.PlayerName.
I'm now assigning UserId = random 6 digits string, on OnJoinedLobby and it works perfectly.

Back to top