Disconnection issues on iOS

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

Oscer21
Posts: 1
Joined: 13 Aug 2022, 04:59
Contact:

Re: Disconnection issues on iOS

Postby Oscer21 » 13 Aug 2022, 05:27

Hello!
I looked for iOS disconnection issues while coming back from background after a short time, and I found long threads in the forum about it, but I didn't see an answer.

My issues is that our iOS clients face frequent lost connections when go to background for a short time (less than idle time). I'm using sfx objective-c version 1.7.10 (I see that there a newer version, but it seems the fixes are not relevant for our issue).

In addition, I've enabled HRC+, so when we back from BG, onConnectionRetry is first called, and onConnectioLost. I suspect server disconnect iOS only client. BTW, same test simultaneously on Android clients works perfectly (as already reported in old topics in the forum.


Please let me know if this issue was fixed and need special handling in iOS clients.

https://www.apkguru.net/gbwhatsapp-apk/
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Disconnection issues on iOS

Postby Lapo » 13 Aug 2022, 08:57

Hi,
My issues is that our iOS clients face frequent lost connections when go to background for a short time (less than idle time). I'm using sfx objective-c version 1.7.10 (I see that there a newer version, but it seems the fixes are not relevant for our issue).

when an app is sent in background the relative connections are lost, there's not much that can be done, because this under control of the OS.

In addition, I've enabled HRC+, so when we back from BG, onConnectionRetry is first called, and onConnectioLost. I suspect server disconnect iOS only client. BTW, same test simultaneously on Android clients works perfectly (as already reported in old topics in the forum.

This depends on how the disconnection is done by the OS. The API will attempt a reconnection but if it fails it fails... unfortunately there's not much else it can be done, other than opening a new one.

As regards this:
I suspect server disconnect iOS only client.

No, the server does not disconnect anyone. That's the client shutting down the connection when the app goes in background.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Aarshi
Posts: 1
Joined: 12 Apr 2023, 07:11
Location: Kazakhstan
Contact:

Re: Disconnection issues on iOS

Postby Aarshi » 12 Apr 2023, 07:48

Experiencing frequent lost connections on iOS clients when returning from background, despite using sfx objective-c version 1.7.10 and enabling HRC+. Android clients work fine. Any known fixes?
Arshi Agarwal FM WhatsApp
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Disconnection issues on iOS

Postby Lapo » 12 Apr 2023, 08:40

Hi,
when mobile apps go in background they drop the connection which can result in a half-closed connection. Unfortunately there's not much that can be done in those instances, as these states are managed at the lower OS level, not by our client API.

For more info on how this works we have written a couple of detailed articles:
https://smartfoxserver.com/blog/what-re ... tworkwifi/
https://smartfoxserver.com/blog/handlin ... e-devices/

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
andersemil
Posts: 10
Joined: 19 Nov 2015, 14:11
Location: Copenhagen, Denmark

Re: Disconnection issues on iOS

Postby andersemil » 12 Oct 2023, 11:17

We're trying to connect to a server on LAN from our Unity iOS client. After calling Connect() the first time, the Connection event is thrown immediately with a success=false parameter. Then the app goes to the background and the OS popup asking for permission to connect to local devices is shown. If the user selects OK, we can call Connect() and then the connection is succesful.

I'm guessing the immediate connection failed is because of this disconnection when the app goes in the background. However, this is not very user-friendly.

Any suggestions how to improve this flow?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Disconnection issues on iOS

Postby Lapo » 12 Oct 2023, 13:19

@andersemil
I need you to clarify a couple of points:
After calling Connect() the first time, the Connection event is thrown immediately with a success=false parameter.

if success==false the connection has failed... did you mean "true" instead?

Then the app goes to the background and the OS popup asking for permission to connect to local devices is shown

Is this something iOS is doing now? I am not familiar with the latest releases. Didn't happen a few releases ago, afaik.

What iOS version are you testing with?
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
andersemil
Posts: 10
Joined: 19 Nov 2015, 14:11
Location: Copenhagen, Denmark

Re: Disconnection issues on iOS

Postby andersemil » 13 Oct 2023, 07:20

Since iOS 14, if you try to open a connection to something on the local network, you get a runtime permission request popup.

My issue was that Smartfox immediately fails to connect BEFORE the popup is shown, which makes it hard to handle.

But I managed to resolve the issue myself by explicitly requesting the permission before calling Connect(), by implementing this stackoverflow answer as a Unity plugin:
https://stackoverflow.com/a/67123856/2837999

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 21 guests