[TIMOB-1893] XHR call fails after network switching
|Fix Version/s||Release 1.5.0|
|Labels||defect, ios, iphone, rplist, xhr|
on iOS 3 & iOS 4 when the device switches from wifi to cellular or vice versa the xhr call errors.
- Stephen Tramer 2011-04-15
There is a very good reason why this behaves the way it does, and the behavior is "correct" and something we have no control over as it happens at the system and hardware level.
WiFi (en0) and data (some other device, I forget) are different interfaces. Say that we have an HTTP request which starts on en0, which is then terminated. This means that the connection to the actual hardware interface has been terminated, which SHOULD be a cancel error. In addition, sometimes hardware is very bad about reporting its status as having the network terminated. In particular, there's the following scenario:
- An HTTP request goes through on WiFi and negotiations are started
- WHILE the request is being processed, WiFi goes down
- But since the request has "completed", timeout doesn't take effect - instead we wait for the response for an indeterminate amount of time
Here is what the user should do instead.
- Watch for reachability changes on their own
- When reachability changes, CANCEL AND RESTART any outgoing HTTP requests
Remember: When using HTTP, you are responsible for managing all of your connection information, up to and including monitoring for reachability changes.
- Lee Morris 2017-03-02 Closed as invalid.