Discussion:
[asio-users] Network disconnect detection on iOS
Pavel Punsky
2014-05-07 07:28:20 UTC
Permalink
When switching iOS device to Airplane mode (no WiFI, Cellular and Bluetooth - this is important as it simulates loss of connectivity like in elevators) there is no error from asio regarding TCP sockets.
Everything looks good as usual - TCP writes succeed, no reads are called. UDP on the other hand does return errors on send.
An error is raised 5 minutes later on TCP socket timeout.

I tried setting lower timeout for receive/send but with no success. Other mobile platforms behave as expected - error is raised as soon as network connection is lost.
Is there a way to overcome this?

There is a way to overcome it by listening to iOS events that notify about changes in network connectivity - in my case that would be a big change in architecture for this specific issue on a single platform. I'll keep it as last resort.

Looking forward for any advice
Igor R
2014-05-07 08:53:12 UTC
Permalink
Post by Pavel Punsky
When switching iOS device to Airplane mode (no WiFI, Cellular and Bluetooth
– this is important as it simulates loss of connectivity like in elevators)
there is no error from asio regarding TCP sockets.
Everything looks good as usual – TCP writes succeed, no reads are called.
UDP on the other hand does return errors on send.
An error is raised 5 minutes later on TCP socket timeout.
It's not iOS specific issue, it's just about how TCP stack is implemented...
To detect "abnormal" disconnections reliably, you'll probably have to
implement an application-level ping/heartbeat mechanism.
See the following discussion:
http://en.it-usenet.org/thread/14891/2089/#post2089
Gruenke,Matt
2014-05-07 18:22:20 UTC
Permalink
When you say that no reads are called, did you have an outstanding async_read(), at the time of connection loss? As I understand it, the most reliable way to detect connection loss is to maintain an outstanding read on the connection. If that doesn't report an error, then it seems like the issue is with iOS. Perhaps this behavior is by design?

A portable workaround would be to use some sort of heartbeat or ping mechanism, if that's available to you. If you can't send anything like that over existing connections, maybe you could try to establish new connections to existing peers or other network addresses you expect to be accessible.


Matt


From: Pavel Punsky [mailto:***@oovoo.com]
Sent: May 07, 2014 03:28
To: asio-***@lists.sourceforge.net
Subject: [asio-users] Network disconnect detection on iOS

When switching iOS device to Airplane mode (no WiFI, Cellular and Bluetooth - this is important as it simulates loss of connectivity like in elevators) there is no error from asio regarding TCP sockets.
Everything looks good as usual - TCP writes succeed, no reads are called. UDP on the other hand does return errors on send.
An error is raised 5 minutes later on TCP socket timeout.

I tried setting lower timeout for receive/send but with no success. Other mobile platforms behave as expected - error is raised as soon as network connection is lost.
Is there a way to overcome this?

There is a way to overcome it by listening to iOS events that notify about changes in network connectivity - in my case that would be a big change in architecture for this specific issue on a single platform. I'll keep it as last resort.

Looking forward for any advice

________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
Loading...