Server disconnect timeout
The whole answer can be found below.
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).
Server disconnect timeout
GLeBaTi
2016-09-30 11:46:04
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?
Comments
Hi @GLeBaTi,
If you want to debug Photon clients connected to self-hosted Photon Server visit this link.
@JohnTube thanks for reply
I am not using PUN (i am using PhotonPeer directly)
InactivityTimeout = "0" not solve my problem :/
I assume you are using native sdk for android, right?
@chvetsov wrote:
I assume you are using native sdk for android, right?
No, i am using Photon Unity3d SDK
I found in "https://doc.photonengine.com/en/realtime/current/reference/known-issues" :
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.
@GLeBaTi is there a reason why you use the "low level" PhotonPeer
"directly" from the Realtime Unity SDK? Why not use LoadBalancingClient
(extend it maybe?) or LoadBalancingPeer
?
Currently, the background thread is available in PUN only.
@Tobias what do you think?
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.
Bump... any updates on this guys?
I too am facing the same issue.
hi, @sid_juego
you may either reconnect as @GLeBaTi did
or ask in dotnet client forum.
best,
ilya
///
/// 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" ??
Back to top