1
votes

Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=54, NSUnderlyingError=0x2834c47b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=54, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask .<1>" ), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://xxx.xxxx.com/xxxx/xxxxx, NSErrorFailingURLKey=https://xxx.xxxx.com/xxx/xxx, _kCFStreamErrorDomainKey=1} [-1005]

Got above error When I am firing api using AFNetworking. I have configured "App Transport Security setting" to allow arbitrary loads. Increased timeout interval of AFNetworking request serializer to 100 seconds. But none helped.

1
Are you sure that both your and the server's network connections are stable?JanBrinker
yes stable. because android is getting their responseAviru
Thanks all for your response. Actually I am working on a quite old project where there are 2 libraries used for networking, ASIHTTP and AFNetworking. I think that as ASIHTTP is based on NSURLConnection, and AFNetworking is based on NSURLSession so there is some kind of conflict or, as ASIHTTP is deprecated so there is some problem occuring.Aviru

1 Answers

1
votes

If you are testing on simulator you might face this issue. I guess the simulator internally may not able to connect to the internet, so that is why it was not able to connect to the server. Try restarting the simulator and check .If it still doesn't work correctly then clear all the content and data for simulator from Hardware --> Erase All Content and Settings.

If you are checking in the real device please check the internet connection of the device.

If the internet connection is working fine then there is some configuration to be done at server end with 'Keep-Alive' value in configuration. I found the same solution at multiple references as below :

https://github.com/AFNetworking/AFNetworking/issues/2801

Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."

Hope this helps.