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.

Disconnect WebGL

virtualsportroom
2022-01-22 00:52:24

Hi Photon

Before starting with the problem I will add the information about the versioning just in case is needed:

Unity 2019.4.34f1

Photon Pun 2 - Pro 2.34.1

Let me know if there is something else I missed.

The problem I am having is that in WebGl after been in the room for a bit, there is a hard disconnect from the server. Also it happen if I change tab in the browser even if I mark in the build to run in the background...

Is there a way to solve this issue?

If not, is there a way to maintain the scene objects after the disconnection, so basically keep offline for that player all the status it was before? as it is a race, it would be weird to reinstanciate everything again.

Comments

JohnTube
2022-01-22 06:18:31

Hi @virtualsportroom,

Thank you for choosing Photon!

It helps to know what DisconnectCause you get from the OnDisconnected callback.

You could make use of SupportLogger to log this.

Read more about disconnects in general here.

virtualsportroom
2022-01-22 20:16:13

I will have a look and come back to you with the cause

Could you tell me in the mean while if there would be a way to keep the scene objects and the player object in the scene even in the disconnect event? so even if the server is disconnected the player could continue offline play?

virtualsportroom
2022-01-22 20:17:55

Is there documentation on how to reconnect from a disconnect of any cause? I didn't find anything in your documentation, just how to know the disconnects and things to check....but not examples of the reconnect or rejoin to the room.

virtualsportroom
2022-01-23 10:54:45

Hi @Johan_Liebert96

The Disconnection cause is ServerTimeOut, but I don't have more information on why the server is giving me timeout.

Can I do something?

Tobias
2022-01-24 17:02:27

The Analyzing Disconnects page also mentions how to rejoin.

Did you read that doc and check if you are maybe sending too much?

virtualsportroom
2022-01-26 08:38:47

I read the documentation, how can I know if I am sending too much?

I did try to use the rejoin but seems not to be working.

It didn't enter even in the first if, so not sure what happened.

Is there a way to activate more log? so I can get some more information?

JohnTube
2022-01-26 13:17:59

I read the documentation, how can I know if I am sending too much?

Maybe make use of Stats GUI or the TarfficStats it uses underneath.

Is there a way to activate more log? so I can get some more information?

Make use of SupportLogger, enable it via PhotonServerSettings.

Or implement all connection and failure callbacks.

virtualsportroom
2022-01-28 23:27:24

In the meanwhile I am using the supportLogger I want to show you my stats so you can advise

This image is with just one player, the master:

This Image is with two players using the second player to see the in messages:

Not sure if those numbers are good or bad, I guess as low is better but Not sure what would be a healthy situation and how to do best practices here.

I will inform with the support logger when I have the information. Thanks you

virtualsportroom
2022-02-08 12:47:55

@JohnTube @Toad1g would it help to send the information in the PunRPC methods in byte[] than in String?

Maybe this could be the cause of the disconnections?

What would be a healthy count of messages from your point of view?

Basically this is a Race game also with bots in a navmesh so I need to transmit the information to the other players on where the bots and the players are at all time.

What would be your recomendation?

virtualsportroom
2022-02-22 00:10:24

@Tobias any kind of advise? Those numbers seems right? it is a project with bots at that point and one player only.

Thank you so much

Tobias
2022-02-22 15:04:27

PUN will not send much, if there is no other player (client) in a room. Above, you said the numbers are recorded for a player and one other client. That should do.

The numbers in the shots don't look terrible, message count wise. The averages are ok, as far as I can see here.

The shots also show one bad value: "Max ms between send" being ~2800 ms. This is too long and cause issues.

Any idea how this happens?

Edit: The byte counts are rather high. 4660402 in 187 seconds? That's almost 25kB per second. Depending on the Max Players for the room, aim to stay under 20kB or 15kB.

Also, the ping time is not great and the ping variance is bad (70ms variance).

Sending ints or bytes instead of strings may help, yes. Reduce bandwidth first, then check if the ping is getting more stable.

virtualsportroom
2022-02-26 21:53:32

Hi @Tobias I believe these numbers are much better, I follow your tips, but still the ping is not getting stable, not sure if I can do something else.

If I follow your calculations now I have around 4.6 kB/s which should be good enough.

Let me know if there is something else I could do to help the ping please, in the mean while I will monitor this and see if the disconnects are happening with these numbers.

Tobias
2022-02-28 11:01:44

You always need to have another player in a room, when you test. Never try to figure out network traffic without the rest of the players, acting like they would in worst case (most to sync). As there is not a lot of incoming traffic, this isn't the worst case.

The ping is really not great. Might want to check if some other region does better. If you use WiFi, get a cable or reduce distance, etc.

Back to top