0

I am using the NSURLSessionUploadTask to upload a file to a server. Once the task is resumed, everyone now and then it fails with the error code

NSURLErrorDomain error -999

Now there is no cancel code anywhere in the app. What causes this to get canceled?

user3570727
  • 10,163
  • 5
  • 18
  • 24

2 Answers2

0

I've run into a similar issue before, the answer for me was that another same request was made before the previous request completed. I would check with breakpoints to see if your method that is uploading the file to the server might be hitting twice. Of course it could be another problem, hard to know without seeing any code but I would start there.

naomimichiko
  • 693
  • 4
  • 10
0

So the -999 in my case was a red herring. There were few misleading information on the iOS side :

  1. The -999 error saying it was cancelled, which is user cancellation. This is not true.
  2. The error message had the NSURLErrorBackgroundTaskCancelledReasonKey set to NSURLErrorCancelledReasonUserForceQuitApplication which was again not correct.

The actual problem was the upload file was too big for the server to accept, so the server cancelled the upload. However the translation of the server canceling the event made the error be -999 with the NSURLErrorCancelledReasonUserForceQuitApplication being the reason.

user3570727
  • 10,163
  • 5
  • 18
  • 24