Disconnect when change Mobile data to Wifi

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

mbgtcx
Posts: 6
Joined: 30 May 2017, 09:35

Disconnect when change Mobile data to Wifi

Postby mbgtcx » 13 Jun 2017, 09:43

Hi,
I'm using Websocket to connect to SFS in my device ( Android or IOS ).
But i change from Mobile data to wifi ( or reverse ), SFS disconnect. When i login again, this notice my account already login.
After few minutes i can login.
This is my config in Zone
Thanks
Attachments
Screen Shot 2017-06-13 at 16.47.14.png
(23.13 KiB) Not downloaded yet
User avatar
Bax
Site Admin
Posts: 4610
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Disconnect when change Mobile data to Wifi

Postby Bax » 13 Jun 2017, 13:14

What API are you using? HTML5/JS or Unity WebGL?
Paolo Bax
The SmartFoxServer Team
mbgtcx
Posts: 6
Joined: 30 May 2017, 09:35

Re: Disconnect when change Mobile data to Wifi

Postby mbgtcx » 13 Jun 2017, 15:17

I using HTML5/JS by Cocos Creator and build to Android and IOS
User avatar
Bax
Site Admin
Posts: 4610
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Disconnect when change Mobile data to Wifi

Postby Bax » 14 Jun 2017, 13:59

The issues with network switch are caused (or not caused) by the underlying operating system.

For example I just created a simple web page which connects to SFS using the JavaScript API. If I test it on my desktop computer and try to pull the network cable (or shut down wifi) I get a result similar to yours: no disconnection event is fired. And if I reactivate the network connection, the client-server communication keeps working as if I didn't do it.

The same application executed on an iPhone (device, not simulator) with iOS 10 and Safari provides different results:
- if I connect over wifi and then switch to cellular, a disconnection event is fired;
- if I connect over cellular and then switch to wifi, the connection keeps working (because actually the cellular network is still available "behind" the wifi one, I suppose);
- if I connect over cellular, then switch to wifi and stop the cellular network, then again a disconnection event is fired.

In other words under iOS the behavior is always the expected one, with the disconnection event being fired when expected.
Maybe Android's underlying behavior is different; unfortunately we don't have a device to test at the moment.

In any case this is not dependent on our API, but the operating system itself.

We suggest the following workaround: in JavaScript listen to the on onoffline and ononline events: they should always be triggered by the system when switching network. You can use them do stop the connection manually and restart it again respectively.
Paolo Bax
The SmartFoxServer Team
mbgtcx
Posts: 6
Joined: 30 May 2017, 09:35

Re: Disconnect when change Mobile data to Wifi

Postby mbgtcx » 15 Jun 2017, 02:08

I will try follow you suggest.
Thanks for reply
User avatar
Bax
Site Admin
Posts: 4610
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Disconnect when change Mobile data to Wifi

Postby Bax » 15 Jun 2017, 08:22

Let us know how you implemented this in Cocos and what the result is. Thanks.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 74 guests