Getting random NSURLErrorCannotConnectToHost (-1004) errors in iOS6.
| Originator: | suhas.shetty | ||
| Number: | rdar://12205422 | Date Originated: | 30-Aug-2012 04:58 PM |
| Status: | open | Resolved: | |
| Product: | iPhone/iPod touch | Product Version: | |
| Classification: | Reproducible: | Yes |
Summary: I am using asynchronous NSURLConnection with a delegate to make HTTP requests in my iOS app. It requires to make lot of HTTP requests to server (in order of 10 requests per second to same host) as, it has 'search as you type' feature with each search making HTTP requests. Some of these requests fail with NSURLErrorCannotConnectToHost (-1004) error. Steps to Reproduce: My app has a UITextField control and I make HTTP requests in textDidChange: delegate of it. Typing a long word will reproduce the problem. Expected Results: All the HTTP requests should be successful as there is connectivity and server is working properly. Actual Results: Most of the requests succeed but some random requests fail with -1004 error. Regression: Getting only one type of error all the time (domain:NSURLErrorDomain code:-1004). Tested in iPod touch (model MD057HN) with iOS 6.0(10A5376e) and iPhone4 (model MC605ZA) with iOS 5.1.1 (9B208). Error occurs only in iPod touch with iOS6 beta. It happens only in iOS6 and not in iOS5.1 and below. Issue is reproducible in different WiFi networks. Most of the time the first request to server after app becomes active from inactive state will fail with error. Notes: Attached is packet trace when the issue occurred. In this trace at least four requests failed with -1004 error. 16-Oct-2012 01:10 AM Apple Developer Bug Reporting Team : Engineering has provided the following feedback and requested some additional information in order to further investigate this issue: In this context, NSURLErrorCannotConnectToHost might mean the server is closing your connections because you have too many connections open. Are you canceling outstanding connections you don't want any more in your search-as-you-type implementation? Reply: Yes. I am canceling outstanding connections which I don't want. The behaviors are different when I cancel and don't cancel. If I don't cancel outstanding connections, I don't get 'NSURLErrorCannotConnectToHost' errors but, the response to the request is received after long time. When I used 'asynchronous NSStream with delegate on main runloop' to carry out HTTP requests I no longer get that error. I think with NSURLConnection the problem still exits.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!