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.

How can I fix the problem of joining the same room after disconnecting from it?

Polakowski94
2021-09-21 07:12:02

Hello,

I'm using the latest PUN and Unity 2021.1.17f1. My problem is, when I disconnect from a room I can't join it again. I can't see it on a list of rooms. I can't join it even if I type its name to join it directly, I get the message that the room doesn't exists. I need to turn off the app or play mode in editor and run the app againt to see that room again. How can I fix that?

Comments

Tobias
2021-09-21 07:59:22

When a room has no active players anymore, it's being cleaned up / deleted.

A EmptyRoomTTL can be set in the RoomOptions (used in the methods that create rooms). Also, a PlayerTTL can be set.

When a player dropped out of a room but the server didn't time out this user yet, then a Join will fail anyways. You have to use Rejoin or even better: ReconnectAndRejoin.

The APIs are described in more detail in the reference PDF and in the docs pages online.

Polakowski94
2021-09-21 08:17:32

Yeah, but the room still has players, I tested it many times with different number of people in the room I disconnected from.

Tobias
2021-09-21 08:54:48

See above: If the server didn't get the disconnect, it may think that the user is still in the room and then you can not join but have to Rejoin.

Of course, you may have closed the room or made it invisible.

Polakowski94
2021-09-21 09:50:44

I just checked that again, the server is getting the disconnect, BUT, it didn't work only for the first time. I checked it with 2 people:

  • They created 2 different rooms, I get OnRoomListUpdate() twice for every room they created, but each time only with one of the rooms

  • I could join any of the rooms, but after I disconnected from it, I couldn't join neither

  • When they disconnected and created new rooms, everything worked just fine

Polakowski94
2021-09-21 10:34:29

I forced my app to connect to TypedLobby I created. When I run it and connect to lobby for the first time, I can only see the rooms that were created by players that also joined the same lobby for the first time. When I connect to one of the rooms or create my own room and diconnect from it, I can only see the rooms that were created by player that also joined or created room and diconnected from it. From now on, everything is working just fine, we can create, join and disconnect any room and we will always see every room we created EXCEPT those rooms created by players that joined the lobby for the first time.

Tobias
2021-09-22 09:10:58

I can only see the rooms that were created by players that also joined the same lobby for the first time.

That sounds really odd. There must be some value which differs between the first time you get into the lobby and the subsequent ones.

Make sure you use the very same TypedLobby (type and name) for JoinLobby as well as for CreateRoom.

Polakowski94
2021-09-22 10:16:48

I'm sure I have the very same TypedLobby, I have only one TypedLobby created in that class and I'm using it everywhere. On Unity Start I call PhotonNetwork.ConnectUsingSettings(), which are the same on every client, and then the client can call PhotonNetwork.JoinLobby(MyTypedLobby) whenever he wants via Unity Button. After he does that he can see list of rooms.

As long as there cannot be two lobbies with the same name and type, all clients are in the same lobby (checked with Debug.Log()). First time they disconnect from lobby and connect to it again, everything is more than ok. The first connection is causing problems, when someone decides to disconnect, because he needs to wait for other players to diconnect for the first time and create new rooms or restart the app.

Tobias
2021-09-23 09:35:00

Can you please try if you can reproduce the issue with the Asteroids Demo? It also has a lobby and should list rooms. You could easily mod it into creating a TypedLobby and use that throughout the game.

Once a client joined a typed lobby, all CreateRoom calls should put the rooms into that lobby (unless you set another lobby in CreateRoom). Make sure your clients are joined to the lobby, or set the lobby in create, too.

I always fall for this issue: CreateRoom can be called via the UI but it can also be called when JoinRandom fails. In a quick test, I put the TypedLobby into CreateRoom only in one place and of course the lobby didn't show that room.

RaghavS
2023-01-30 07:54:07

Asteroids Demo

You are talking about Space Shooter Tutorial [Legacy] when imported into the project is giving me 125 errors atleast. So how should one check this

And also when i left the room i m using Photon Network.leave Room to leave the room and than Loading the Lobby Scene......It works perfect but when i try to join the same room again from lobby my player joins the room in unity editor and than game got paused and player is showing and when i again continues the game my player got disconnected ??

Have tried so many different solutions but they won't work.

I want to ask that what is the way that when I come to lobby and than again join the main room so that my player won't disconnects from photon ??

Back to top