Mobile web apps do not survive changing from cell data to wifi data

If you’re running a mobile web app on your phone and you suddenly walk into wifi range (or out of it) the app becomes unresponsive. No error message or disconnect message is displayed, it just stops working.

You can easily duplicate this by starting your app on wifi and then turning wifi off, the app will happily sit there as a cell data connection is opened, and you can see the spinner showing it’s trying to send data when you click on something, but nothing will ever happen.

Would it be possible to reconnect to the session when you connect from the same device via a different interface? The cookies and other data that identify the connection should still be valid. Perhaps this is overzealous security? Or perhaps it just wasn’t something anyone though would happen.

1 Like

The problem is that your session is tied to your IP address and when you switch networks, it changes.

Thats part of the fun of being on a mobile connection, your IP is going to change periodically :slight_smile: I believe it should be able to follow me across changes given other information in the conversation. At the very least it should give me an error message instead of just sitting there not doing anything?

Is this something that IPV6 solves? (my guess is “no”)

I know you have been to https://forum.xojo.com/21408-ios-web-apps-timeout-gracefully ;

Seems to me your issue is not quite different. Using the setTimeOut/Pushback method, your app could display a msgbox when connection is lost, instead of being stuck.

Albin had found that this problem was solved with HAproxy:

https://forum.xojo.com/10913-load-balancing-web-standalone/p2#p168932

http://john-joyce.com/xojo-and-load-balancing-with-haproxy/

But it would be a good Feedback to add to improve the framework:

https://forum.xojo.com/20298-feature-requests-to-improve-web-apps/p1#p170425

If an application could display a wait message when it loses the network (rather than close / crash) and if it could stay connected when changing network (change wifi network, failover on mobile network…), it would be a big improvement. We live in a mobile world today! So in a world where there may be temporary disconnections, failover between network (wifi / mobile network …), etc.

Just tried this again by going to my load balanced app while in my Wi-Fi network and when turning Wi-Fi off I’m still in the app without loosing the connection :slight_smile:

I did not quite get what you explained in the other thread. Typically, you are on Wifi , disconnect from it, then reconnect minutes later through cellular data or from another wifi network, and with different IP, and the session has been maintained alive by the proxy ?

If I’m on a Wifi network and loose the connection to said network, I’m still connected to the app over a 4G connection(or what ever) instead.
You cannot close the browser and open it at a later time to be reconnected and resume were you left off. That does not work.
Don’t know for how long the connection will be kept alive but that might be a setting in the proxy config.

[quote=179660:@Albin Kiland]If I’m on a Wifi network and loose the connection to said network, I’m still connected to the app over a 4G connection(or what ever) instead.
You cannot close the browser and open it at a later time to be reconnected and resume were you left off. That does not work.
Don’t know for how long the connection will be kept alive but that might be a setting in the proxy config.[/quote]

That is great !

Came across this thread searching for a solution.

The Web app only loads on wifi/ethernet connection…refuses to load on 4g or 3g?

Is there a solution for this? Oddly, one wifi connection I tried was slower than the 4G connection, yet somehow the app knows the difference between data and wifi? I thought initially the problem was speed, but this is surely not the case.

Try it out:
api.simulanics.com:8899

works fine on my Nexus 5 with the wifi turned off. It does take a while to connect and once connected, the login dialog is off the screen, but it is possible to scroll laterally to reach it.

Ok. Must be certain carriers. I’ve had a few individuals test and…

Verizon - Fail
ATT - Success
TMobile - Success
Virgin - Success

Some carriers can be a bit particular about the port being used.

With Apache reverse proxy, it seems that we obtain the same behavior.

Yes, using a reverse proxy or load balancer will effectively bypass the mechanism that is built into the web framework for managing individual sessions. It also means that you’ll likely not be able to have multiple sessions open on the same browser/device at the same time.

Yepp. A quick look at the session cookie with multiple windows open in the same browser and they are equal.
Any way to prevent that maybe? :slight_smile: Or is that something I would have to configure in HAProxy somehow…?

[quote=195718:@Albin Kiland]Yepp. A quick look at the session cookie with multiple windows open in the same browser and they are equal.
Any way to prevent that maybe? :slight_smile: Or is that something I would have to configure in HAProxy somehow…?[/quote]
Once you do that, then you have the wifi vs cellular problem again.

Time to update this thread because of the addition of WiFi Assist to the latest iOS update. That new feature makes iOS web apps extremely unreliable and frustrating to use.

What WiFi assist does is time the latency of opening a connection over wifi. If you’re at the edge of the range or if the wifi is just really hung up with lots of traffic and your connection isn’t quickly acked it will attempt to make the same connection over the cell radio. Whichever socket actually opens first it will use that one.

This means that people connecting to your apps now may be doing so from 2 different IP addresses. Not just at a wifi switchover as before, but randomly back and forth many times. The connection from one will work, the other will do nothing and display no error message.

With that new feature it has become somewhat of a priority for me to bug folks about this again. If your wifi is at all dodgy then about half your clicks will never register on the server and half the server updates will never make it to your app. We need a session that can survive on multiple IP addresses now. It’s no longer sensible to consider a change of IP to be a security problem.

<https://xojo.com/issue/38890>