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.

Internet connection issues

Maheshk_218
2018-12-22 11:09:09

Hi , We have integrated PUN for one of our game. We are facing some issues related to internet connection.
Player 1 and Player2 connected in one of the PvP game. Some time later Player 1 lost internet connection for 3 seconds and came back. Player2 got an event immediately after player1 lost connection, but player1 didn't received any event related to failure connection immediately (Received after 60 sec), and for player1 still showing connected TRUE.
Other issues is even after player1 got internet connection , message passing is not happening between two players.

Comments

JohnTube
2018-12-25 10:24:56

Hi @Maheshk_218,

Thank you for choosing Photon!

You also sent us an email regarding this.
I will reply here as well and I think we should continue the discussion here:

but player1 didn't received any event related to failure connection immediately (Received after 60 sec), and for player1 still showing connected TRUE.
I don't think the 60 seconds is accurate here maybe it's 10 seconds? as 10 seconds is the client timeout period and 60 seconds is the default background timeout period. Also, it is expected that the client does not know he is disconnected due to timeout only after the timeout period has ended which is 10 seconds and not 60 seconds.
Other issues is even after player1 got internet connection , message passing is not happening between two players.
In any case, you need to recover from unexpected disconnects by reconnecting (PhotonNetwork.Reconnect()) and rejoining the room if necessary (PhotonNetwork.ReconnectAndRejoin()).

If you think that PUN client state is not correct and not reliable, here is what I suggest:
send us the repro env. details and minimal repro steps:

  • PUN version
  • Unity version
  • description of the issue: e.g. expected behavior vs. the actual behavior you see

You could increase log levels, add SupportLogger component and send us logs.
Also, make sure to implement disconnection callbacks and log the disconnection cause/reason.

Otherwise, here are some documentation links:

ajaybirla
2018-12-26 13:13:22

Hi @JohnTube,

Thanks for replying.

I don't think the 60 seconds is accurate here maybe it's 10 seconds? as 10 seconds is the client timeout period and 60 seconds is the default background timeout period.
You're correct, 10 Secs is Client timeout and 60 Secs is Background timeout but we're getting 60 Secs to get OnPhotonPlayerDisconnected in Unity Editor. We need Disconnect event as soon as possible.

Also, this 60 Secs of Background timeout will work for both Android/iOS?

Also, it is expected that the client does not know he is disconnected due to timeout only after the timeout period has ended which is 10 seconds and not 60 seconds.
So there will be no Disconnect event from Photon side if client timeouts? No OnDisconnectedFromPhoton? No OnPhotonPlayerDisconnected? How to handle this situation?
In any case, you need to recover from unexpected disconnects by reconnecting (PhotonNetwork.Reconnect()) and rejoining the room if necessary (PhotonNetwork.ReconnectAndRejoin()).
Other issues is even after player1 got internet connection , message passing is not happening between two players.
Client lost internet and after sometime again connected to internet but we're not getting any Disconnect event so we don't know How/When to call Reconnect.

Is there any suggested way to handle all Disconnect/Reconnect events?

JohnTube
2018-12-26 13:58:02

Hi @ajaybirla,

Thank you for choosing Photon!
I'm assuming you work with @Maheshk_218.

but we're getting 60 Secs to get OnPhotonPlayerDisconnected in Unity Editor
My understanding: a remote client, probably an Android build client has disconnected because the application went to the background for more than 60 seconds.
Also, this 60 Secs of Background timeout will work for both Android/iOS?
No only Android, iOS does not allow background threads.
So there will be no Disconnect event from Photon side if client timeouts? No OnDisconnectedFromPhoton? No OnPhotonPlayerDisconnected? How to handle this situation?
Is there any suggested way to handle all Disconnect/Reconnect events?
What you could do is:

1- Implement the proper disconnection callback

void OnConnectionFail (DisconnectCause cause)
. The other callbacks are for other purposes, see the documentation per callback.
2- For iOS you could handle this using Unity's OnApplicationPause by explicitly/manually disconnecting and reconnection. See Unity RunInBackground.
3- Add an early timeout detection heuristics and manually force client disconnection/reconnection...Take a look at this post by my colleague here

You cannot change server timeout window for Photon Cloud but I think you could do it for self-hosted Photon Server (see here).

Maheshk_218
2018-12-27 07:53:41

Hi @JohnTube ,

Thanks for your responses.

When player1 lost the connection, is there any way to send the buffered messages from player2 after reconnection. (ie while PvP game if one player lost the connection , then how to store the buffered messages and send it back when both reconnected again. did photon has an options store the buffered messages or we need to manually store and send them back on reconnection).
I know there is buffered RPC's but want to know wether it will work in above scenarios.

JohnTube
2018-12-27 09:57:45

Hi @Maheshk_218,

Buffered RPCs (which are Cached Events under the hood) are resent on reconnection yes.
You may need to clean up RPCs or events not needed anymore or filter those already received and processed if you get duplicate events on rejoin...

Maheshk_218
2018-12-29 14:17:55

@JohnTube I am looking for RPC's that happened only after player disconnect. But Photon have system to recieves all the RPCs from the begining of the game. So for now we achieved this by having MasterClient to send the buffered RPC's to re-connected player by cacheing them manually.

Back to top