Internet connection issues
Options
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.
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.
0
Comments
-
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
Also, make sure to implement disconnection callbacks and log the disconnection cause/reason.
Otherwise, here are some documentation links:
- Mobile Background Apps
- Client Connection Handling
- Analyzing Disconnects
- Master Client and Host Migration0 - PUN version
-
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()).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.Other issues is even after player1 got internet connection , message passing is not happening between two players.
Is there any suggested way to handle all Disconnect/Reconnect events?
0 -
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 EditorMy 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 callbackvoid OnConnectionFail (DisconnectCause cause). The other callbacks are for other purposes, see the documentation per callback.
2- For iOS you could handle this using Unity'sOnApplicationPause
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).0 -
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.
0 -
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...0 -
@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.
0