Hi
My iOS clients suffer from connection loss when going to the background for a few seconds. (iOS probably kill the TCP socket?)
I wanted to ask for your suggestion on how can I overcome the iOS disconnections because my game is not tolerant of those disconnections. When the connection drop, I can't really overcome this situation, so I kind of reset the game behind the scene.
If I could somehow prevent iOS from killing the TCP socket for a 1/2 min when the user goes to the background it will be enough for me. Most of our complaints are users that went to BG for less than 10 sec.
From your experience, can I prevent it somehow? I don't have a background capability set, may it help? (https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/about_the_background_execution_sequence)
iOS| Disconnection during app in background
-
- Posts: 25
- Joined: 28 Jun 2020, 08:54
Re: iOS| Disconnection during app in background
Hi,
it is possible that iOS does that, especially if the connection is idle. It also depends on the iOS version. For instance it looks like iOS 13 is pretty aggressive at killing background processes and connections, as per this article: https://www.idownloadblog.com/2019/10/3 ... anagement/
My suggestion is to try with a "keep alive" system. Something that keeps sending small requests every few seconds to keep the connection up. The LagMonitor feature in the SFS2X client API might do the trick.
The feature is used to keep track of the client-server roundtrip time, by sending a ping to the server every 4 seconds.
Under Objective-C you can do this:
after a successful login.
Hope it helps
it is possible that iOS does that, especially if the connection is idle. It also depends on the iOS version. For instance it looks like iOS 13 is pretty aggressive at killing background processes and connections, as per this article: https://www.idownloadblog.com/2019/10/3 ... anagement/
My suggestion is to try with a "keep alive" system. Something that keeps sending small requests every few seconds to keep the connection up. The LagMonitor feature in the SFS2X client API might do the trick.
The feature is used to keep track of the client-server roundtrip time, by sending a ping to the server every 4 seconds.
Under Objective-C you can do this:
Code: Select all
[sfsClient enableLagMonitor: YES];
after a successful login.
Hope it helps
-
- Posts: 25
- Joined: 28 Jun 2020, 08:54
Re: iOS| Disconnection during app in background
Thanks for the quick response, I will try it!
-
- Posts: 25
- Joined: 28 Jun 2020, 08:54
Re: iOS| Disconnection during app in background
It doesn't help. once the screen turns off the OS probably close all the sockets excepts for VOIP.
Re: iOS| Disconnection during app in background
Unfortunately I don't think there's much you can do about it, especially in a game. That's just how the OS manages the processes that are not active. Background Tasks can be used to run a task while the app is not in focus, but there're restrictions there too, especially when the phone goes to sleep.
Unfortunately I don't think this solution is suited for a game. The best idea would be to have a "save state" feature on the server side that can maintain the state of the game while clients are not active/in background etc... From client side you can detect the foreground/background state changes and kill the connection or create a new one, then request the previous game state and continue. (Provided your game logic supports this kind of approach).
Cheers
Unfortunately I don't think this solution is suited for a game. The best idea would be to have a "save state" feature on the server side that can maintain the state of the game while clients are not active/in background etc... From client side you can detect the foreground/background state changes and kill the connection or create a new one, then request the previous game state and continue. (Provided your game logic supports this kind of approach).
Cheers
Return to “SFS2X iPhone / iPad / OSX API”
Who is online
Users browsing this forum: No registered users and 36 guests