Reconnecting to photon server.
Hi,
I have an issue about reconnecting to photon server when when network is lost.
To do it, I have set disconnection timeout in both client and photon server by using "PhotonNetwork.networkingPeer.DisconnectTimeout" in client side and config "InactivityTimeout" in photon server side.
I hope when network is lost, client will wait during the timeout period (to reconnecting) before the event "OnConnectionFail" and "OnFailedToConnectToPhoton" are triggered .
But when I debugged, 2 event "OnConnectionFail" and "OnFailedToConnectToPhoton" are triggered as soon as the network is lost with the cause is "DisconnectByServerTimeout"
I don't know why the "timeout" parameter I set haven't effect.
I have an issue about reconnecting to photon server when when network is lost.
To do it, I have set disconnection timeout in both client and photon server by using "PhotonNetwork.networkingPeer.DisconnectTimeout" in client side and config "InactivityTimeout" in photon server side.
I hope when network is lost, client will wait during the timeout period (to reconnecting) before the event "OnConnectionFail" and "OnFailedToConnectToPhoton" are triggered .
But when I debugged, 2 event "OnConnectionFail" and "OnFailedToConnectToPhoton" are triggered as soon as the network is lost with the cause is "DisconnectByServerTimeout"
I don't know why the "timeout" parameter I set haven't effect.
0
Comments
-
I used:
Photon server: Photon-OnPremise-Server-SDK_v4-0-29-11263
Unity: 2017.1.1f1
0 -
Hi @dzungvd,
Thank you for choosing Photon!
I want to understand what you are trying to achieve here:
- set a timeout value different than default one? which is 10 seconds I believe.
- set a high timeout value to be able to debug client code (breakpoints etc.). In this case take a look here.
In any case:
- what protocol are you using? UDP or TCP?
- what PUN version is this?
-PhotonNetwork.networkingPeer.DisconnectTimeout
should be in milliseconds.0 -
Hi @JohnTube ,
Thank you for replying me.
- The timeout value is default one. I don't change anything (10 seconds).
- The connection prototol that I'm using is TCP.
- PUN version is: 1.85.
- PhotonNetwork.networkingPeer.DisconnectTimeout is default value (10000 milliseconds)
- And the error log in this case:
Receiving failed. SocketException: ConnectionAborted
UnityEngine.Debug:LogError(Object)
NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1522)
ExitGames.Client.Photon.<>c__DisplayClass145_0:b__0()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)
0 -
So what are you asking?
What do you want?
You want to change disconnect timeout for TCP on server side? Is that it?0 -
the client can't reconnect to photon server.What happens if you call
Reconnect
orConnect
again in the callback?the cause is "DisconnectByServerTimeout"Do you always get the same disconnect reason?Receiving failed. SocketException: ConnectionAbortedDo you always get the same SocketException "reason"?I want to recover the network lost connectivity and I use parameter disconnection timeout to do it.Why? You do not need to change anything to allow clients to recover lost connectivity. Just callReconnect
orConnect
again when you detect the disconnection.
What I suggest:
- Update PUN to latest version
- Reset the changes you made on server configuration regarding the timeout value and try again or send us the config part you changed to review it.0 -
Hi @JohnTube ,What happens if you call Reconnect or Connect again in the callback?
had an error occur: An item with the same key has already been added.Do you always get the same disconnect reason?
Do you always get the same disconnect reason?
Yes, I always get the same disconnect and SocketException reason
The configuration that I config on server: the link
0 -
Receiving failed. SocketException: ConnectionAbortedDisconnectByServerTimeoutAn item with the same key has already been added.
All this information indicates that most likely:
There is something in your client code that is causing an error or exception on server or client after connecting.
I think client manages to reconnect but something wrong happens after that.
You should debug this and see what you are doing after reconnection.0 -
Read about the disconnect cause,
DisconnectByServer
:It indicates low level protocol error which can be caused by data corruption.This means that an exception in Photon Server caused the client to disconnect.
if you use self hosted you should see exception details in the unmanaged Photon Socket Server log ("/bin_WinXXX/log/Photon-(InstanceName)-Timestamp.log")0