Server disconnect timeout
GLeBaTi
✭
Hello. I have android game with photon. Android games is not working in background (android specific)
When i hide(minimize) the game, after 10 seconds i have on server:
On client (when i open the game (maximize)):
How can i increase timeout?
When i hide(minimize) the game, after 10 seconds i have on server:
OnDisconnect - ConnID=52 reasonCode=ClientDisconnect
Connection state changed from Connected to Disconnected
OnDisconnect: conId=109.195.243.29, reason=ClientDisconnect, reasonDetail=
IUMobilePeer: User disconnected
Connection state changed from Disconnected to Disposed
Connection state changed from Connected to Disconnected
OnDisconnect: conId=109.195.243.29, reason=ClientDisconnect, reasonDetail=
IUMobilePeer: User disconnected
Connection state changed from Disconnected to Disposed
On client (when i open the game (maximize)):
PhotonDebugReturn: Receiving failed. SocketException: WouldBlock
Status code:InternalReceiveException
Status code:Disconnect
Status code:InternalReceiveException
Status code:Disconnect
How can i increase timeout?
0
Comments
-
I assume you are using native sdk for android, right?0
-
I found in "https://doc.photonengine.com/en/realtime/current/reference/known-issues" :Mobile - Home Button Causes Disconnect
On (most) mobiles, applications are not allowed to keep a connection when they are in the background. There are next to no exceptions to this rule (e.g. see Background Execution on the Apple dev pages).
When a game gets focus again within (approximately) 10 seconds, PUN will try to continue the game. Any pause longer than that will lead to a timeout. There is a chance that the server side timed out the client meanwhile.
Due to the nature of iOS also shutting down the app immediately, a "timeout disconnect" callback naturally gets known to your app only when it's executing again.
There are system callbacks by iOS when an application goes to the background and when it gets focus again. Use those to disconnect. If the game design can allow a player to return even after several seconds or minutes, then you could also re-connect and join the game again.0 -
Becouse i have only one server. I don't need load balancing/
background threads also not working in background in android.
Now i make reconnect on game gets focus again.0 -
Bump... any updates on this guys?
I too am facing the same issue.0 -
0
-
///
///
/// Defines how many seconds PUN keeps the connection, after Unity's OnApplicationPause(true) call. Default: 60 seconds.
///
/// It's best practice to disconnect inactive apps/connections after a while but to also allow users to take calls, etc..
/// We think a reasonable backgroung timeout is 60 seconds.
///
/// To handle the timeout, implement: OnDisconnectedFromPhoton(), as usual.
/// Your application will "notice" the background disconnect when it becomes active again (running the Update() loop).
///
/// If you need to separate this case from others, you need to track if the app was in the background
/// (there is no special callback by PUN).
///
/// A value below 0.1 seconds will disable this timeout (careful: connections can be kept indefinitely).
///
///
/// Info:
/// PUN is running a "fallback thread" to send ACKs to the server, even when Unity is not calling Update() regularly.
/// This helps keeping the connection while loading scenes and assets and when the app is in the background.
///
/// Note:
/// Some platforms (e.g. iOS) don't allow to keep a connection while the app is in background.
/// In those cases, this value does not change anything, the app immediately loses connection in background.
///
/// Unity's OnApplicationPause() callback is broken in some exports (Android) of some Unity versions.
/// Make sure OnApplicationPause() gets the callbacks you'd expect on the platform you target!
/// Check PhotonHandler.OnApplicationPause(bool pause), to see the implementation.
///
and now, where exactly is "PhotonHandler.OnApplicationPause" ??0