7 Replies
      Latest reply: Dec 11, 2016 3:02 PM by eskimo RSS
      james8912 Level 1 Level 1 (0 points)

        Hi, I am getting -1005 and -1009 error codes intermittently on network requests for iOS10 on both iPhone and iPad. One suggested fix online is to simply perform a retry. Does either of these error codes along with status code 0 guarantee the request never hit the server and therefore always safe to perform a retry (particularly concerned about POST requests as they are changing state on server side)?

        • Re: Is it safe to retry -1005 error code on network request
          eskimo Apple Staff Apple Staff (6,310 points)

          Does either of these error codes along with status code 0 guarantee the request never hit the server and therefore always safe to perform a retry …

          Error -1005 is NSURLErrorNetworkConnectionLost and it’s definitely not safe to retry non-idempotent requests in that case.  This error indicates that the TCP connection carrying the HTTP request tore before we got the response.  There’s two possibilities:

          • The request did not make it to the server.

          • The request made it to the server but the response didn’t make it back to the client.

          In the second case a blind retry will cause problems.  To avoid this, you must implement app-specific logic to query the server to see if the first request made it.

          In contrast, error -1009 is NSURLErrorNotConnectedToInternet, which means the request probably didn’t make it off the device.  However, given that you have to implement app-specific recovery logic to handle NSURLErrorNetworkConnectionLost, it’s better IMO to ignore the specific error code and use that logic always.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"