[iOS]Error Domain=NSURLErrorDomain Code=-1005 “The network connection was lost.”
3817 단어 iosConnectionerror
I have application which works fine on Xcode6-Beta1 and Xcode6-Beta2 on both iOS7 and iOS8 but, in Xcode6-Beta3, Beta4, Beta5 facing network issue on iOS8 but works fine on iOS7. I recieve error:
“The network connection was lost.”.
The error printed was as follows:
error: Error Domain=NSURLErrorDomain Code=-1005 “The network connection was lost.” UserInfo=0x7ba8e5b0 {NSErrorFailingURLStringKey=, _kCFStreamErrorCodeKey=57, NSErrorFailingURLKey=, NSLocalizedDescription=The network connection was lost., _kCFStreamErrorDomainKey=1, NSUnderlyingError=0x7a6957e0 “The network connection was lost.”}
I use AFNetworking 2.x and following code snippet to make network call:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager setSecurityPolicy:policy];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager POST:<example-url>
parameters:<parameteres>
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@“Success: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }];
I tried with NSURLSession and still I receive the same error.
Answers: Restarting the simulator fixed the issue for me.
We add this exact error and it turned out to be an issue with the underlying HTTP implementation of NSURLRequest:
As far as we can tell, when iOS 8 receive an HTTP response with a Keep-Alive header, it keeps this connection to re-use later (as it should), but it keeps it for more than the timeout parameter of the Keep-Alive header and then when a second request comes it tries to re-use a connection that has been dropped by the server.
As a monkey patch if anybody else is having this issue, you can add BrowserMatch “^iOS/8.” nokeepalive (with the correct user agent) somewhere in your Apache server config (This is nowhere near perfect but makes things work until Apple patches iOS8).
For mine, Resetting content and settings of Simulator works. To reset the simulator follow the steps:
iOS Simulator -> Reset Content and Settings -> Press Reset (on the warning which will come)
The iOS 8.0 simulator runtime has a bug whereby if your network configuration changes while the simulated device is booted, higher level APIs (eg: CFNetwork) in the simulated runtime will think that it has lost network connectivity. Currently, the advised workaround is to simply reboot the simulated device when your network configuration changes.
If you are impacted by this issue, please file additional duplicate radars at http://bugreport.apple.com to get it increased priority.
If you see this issue without having changed network configurations, then that is not a known bug, and you should definitely file a radar, indicating that the issue is not the known network-configuration-changed bug.
참조:http://stackoverflow.com/questions/25372318/error-domain-nsurlerrordomain-code-1005-the-network-connection-was-lost
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Swift의 패스트 패스Objective-C를 대체하기 위해 만들어졌지만 Xcode는 Objective-C 런타임 라이브러리를 사용하기 때문에 Swift와 함께 C, C++ 및 Objective-C를 컴파일할 수 있습니다. Xcode는 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.