1 Reply
      Latest reply on Nov 26, 2018 1:40 AM by eskimo
      ioplop Level 1 Level 1 (0 points)

        I am using Xcode 10 and facing a crash on my iPhone running on iOS 12. The issue is put the application in the background, wait for few seconds and restore it to foreground state using firebase notification or directly open the app.


        I am using Alamofire for requests, If the user briefly puts the app into the background, the URL request gets cancelled with the error 53 above.

        I noticed the same is true for any url request that does not complete while the app is active.

        • Re: load failed with error Error Domain=NSPOSIXErrorDomain Code=53 "Software caused connection abort"
          eskimo Apple Staff Apple Staff (13,325 points)

          When your app is moved to the background, the system will typically suspend it.  And once your app is suspended the system may reclaim resources from your network connections, which essentially tears those connections.  You can read Technote 2277 Networking and Multitasking for more details about this.

          How best to deal with this depends on type of requests:

          • For short-running requests you can use a UIApplication background task to prevent your app from being suspended on moving to the background.

            Note UIApplication background tasks can be a bit tricky.  See my UIApplication Background Task Notes post for some hints and tips.

          • If you’re dealing with a long-running request — for example, downloading a large file — you should use an NSURLSession background session so that the system can continue the work even if your app gets suspended.

          Share and Enjoy

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