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
Disconnect when change Mobile data to Wifi
Disconnect when change Mobile data to Wifi
- Attachments
-
- Screen Shot 2017-06-13 at 16.47.14.png
- (23.13 KiB) Not downloaded yet
Re: Disconnect when change Mobile data to Wifi
What API are you using? HTML5/JS or Unity WebGL?
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: Disconnect when change Mobile data to Wifi
I using HTML5/JS by Cocos Creator and build to Android and IOS
Re: Disconnect when change Mobile data to Wifi
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.
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
The SmartFoxServer Team
Re: Disconnect when change Mobile data to Wifi
I will try follow you suggest.
Thanks for reply
Thanks for reply
Re: Disconnect when change Mobile data to Wifi
Let us know how you implemented this in Cocos and what the result is. Thanks.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Who is online
Users browsing this forum: No registered users and 74 guests