Turning WIFI off
-
ApolloMeijer
- Posts: 58
- Joined: 16 Aug 2012, 10:05
Turning WIFI off
Hey,
I am testing the HRC system.
If I run the app on my android device ( its a unity application ) and turn of the system WIFI I expect it to continue using my 3G / 4G connection.
But it doesn't, it retries once and then it already triggers the connection lost event.
Is this suppose to happen?
Thanks for reading, Apollo
Youdagames.
I am testing the HRC system.
If I run the app on my android device ( its a unity application ) and turn of the system WIFI I expect it to continue using my 3G / 4G connection.
But it doesn't, it retries once and then it already triggers the connection lost event.
Is this suppose to happen?
Thanks for reading, Apollo
Youdagames.
Re: Turning WIFI off
I would have expected that the HRC wouldn't even get triggered.
On most computer OSes switching off the WIFI doesn't do anything. In other words it doesn't trigger a disconnection.
What version of the C# API are you using?
What setting are you using for the reconnection time in your Zone config?
Thanks
On most computer OSes switching off the WIFI doesn't do anything. In other words it doesn't trigger a disconnection.
What version of the C# API are you using?
What setting are you using for the reconnection time in your Zone config?
Thanks
-
ApolloMeijer
- Posts: 58
- Joined: 16 Aug 2012, 10:05
Re: Turning WIFI off
Hey
I have the userReconnectionSeconds parameter set to 30.
When I turn of my WIFI on the phone. The server responds by saying it is trying to reconnect and has 29~ seconds left. And then it just instantly triggers the disconnect event.
Any idea?
I have the userReconnectionSeconds parameter set to 30.
When I turn of my WIFI on the phone. The server responds by saying it is trying to reconnect and has 29~ seconds left. And then it just instantly triggers the disconnect event.
Any idea?
-
ApolloMeijer
- Posts: 58
- Joined: 16 Aug 2012, 10:05
Re: Turning WIFI off
I just noticed it traces this error now, for some reason debugging was turned off.
com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/85.255.209.213:9933 remote=/92.69.250.189:3150]
com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:146)
com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:131)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:744)
UPDATE: It also triggers the disconnect event when i have WIFI turned off, i play with 3G and then turn WIFI on.
com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/85.255.209.213:9933 remote=/92.69.250.189:3150]
com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:146)
com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:131)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:744)
UPDATE: It also triggers the disconnect event when i have WIFI turned off, i play with 3G and then turn WIFI on.
Re: Turning WIFI off
It's difficult to say what might be going on. The connect/disconnect events are triggered by the OS at TCP level, so the API and server can only rely on those.
From the errors I see it seems that the client is trying to reconnect but it is too late.
Which server version are you using?
From the errors I see it seems that the client is trying to reconnect but it is too late.
Which server version are you using?
-
ApolloMeijer
- Posts: 58
- Joined: 16 Aug 2012, 10:05
Re: Turning WIFI off
I am using smartfox server 2.8.2 and unity api 1.5
The smartfox serverside extension is not receiving any connection lost event. it seems to be just the client.
The smartfox serverside extension is not receiving any connection lost event. it seems to be just the client.
-
JuliusBtesh
- Posts: 58
- Joined: 30 Sep 2014, 17:08
Re: Turning WIFI off
Have you ever solved this? Because I realized I am experiencing the same thing which won't be good for a production app. If the Wi-Fi turns off then it should automatically use the phone internet but this doesn't seem to be the case
Re: Turning WIFI off
This is a problem almost all mobile developers encounter.
A little bit of background: TCP/IP was not designed with mobile devices in mind. It was created in the mid 70s when computers were moved almost exclusively with cranes
When you are connecting your client to the server (using TCP) the connection is persistent, meaning that it cannot be "moved around". This in turn implies that if you can switch between multiple sources of internet connections (WIFI, 3G, 4G...) you will have to reset your connection.
If you don't you will likely encounter problems.
The best approach is to listen for a connectivity change via your mobile OS (Android, iOS...), close the current connection (if any) and restart a new connection to the server.
In doing so make sure to release any previous listeners (to avoid memory leaks) and create a brand new SmartFox instance.
Hope it helps
A little bit of background: TCP/IP was not designed with mobile devices in mind. It was created in the mid 70s when computers were moved almost exclusively with cranes
When you are connecting your client to the server (using TCP) the connection is persistent, meaning that it cannot be "moved around". This in turn implies that if you can switch between multiple sources of internet connections (WIFI, 3G, 4G...) you will have to reset your connection.
If you don't you will likely encounter problems.
The best approach is to listen for a connectivity change via your mobile OS (Android, iOS...), close the current connection (if any) and restart a new connection to the server.
In doing so make sure to release any previous listeners (to avoid memory leaks) and create a brand new SmartFox instance.
Hope it helps
-
JuliusBtesh
- Posts: 58
- Joined: 30 Sep 2014, 17:08
Re: Turning WIFI off
Ok so thank you for that. I have created a function that will check the changes in connectivity and when it notices a change, it will reset the smartfox object and connect again. That works and I get a successful connection but now what? Do I need to login the user again? Because if I dont touch anything for a moment, I get a connection lost callback right after successfully connecting and I think it happens due to no logged in user and the session running out.
Re: Turning WIFI off
Yes, a login is necessary. Basically you're restarting from the beginning, including the fact that you're loosing your current game state, if the user was playing.
This is not very convenient, but there's no workaround. It's just how TCP works.
Depending on how your game logic works you should be able to create a reconnection logic that allows the player to start from where he left.
cheers
This is not very convenient, but there's no workaround. It's just how TCP works.
Depending on how your game logic works you should be able to create a reconnection logic that allows the player to start from where he left.
cheers