Search code examples
iosafnetworking-2

AFNetworking sometimes not working on iOS 8 & 9 at real device


I develop app for iOS8 & iOS9.
Recently I came the situations that HTTP networking cannot access Rails server at real iOS8 & iOS9 devices. This was often happened iOS9 but iOS8 was sometimes. This problem is not consistency, sometimes first network access is OK, but third or fourth access can not work. the The simulators can always access server.
Of corse I know ATS and I set what all http access is OK.

Environmental
Xcode 7.1.1
CocoaPods 0.39.0
AFNerworking(use AFHTTPSessionManager) 2.6.1
real device iPhone5S iOS8.2
real device iPhone6 iOS9.1

Error Log
Domain=NSURLErrorDomain Code=-1001
I think that there may be other errors, but I forgot it.

If anyone know the answer, please tell me.


Solution

  • According to the Apple's CFNetwork error documentation the "-1001" value actually stands for:

     kCFURLErrorTimedOut  = -1001
    

    So easy enough the main problem here is your internet speed and quality, especially when you use a mobile device in a poor signal situation. My suggestion would be to update to the latest version of AFNetworking from the official GitHub project page and test again using also a Wi-Fi connection if the problem appears again.

    If you keep facing this issue please post some code if you can so we can see what's wrong. By the way, have you changed the network timeout timer? Is so, reset it to the default value, a short value could cause this.