When trying to upload multiple files(near about 40 with average size of each file 3-4 MB) to the server using NSURLSession uploadTask getting this error: "Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service""

When trying to upload multiple files(near about 40 with average size of each file 3-4 MB) to the server using NSURLSession uploadTask, getting this error: "Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service"" in nsurlsession delegate method "didCompleteWithError".

Replies

Error -997 is

NSURLErrorBackgroundSessionWasDisconnected
. One obvious cause of this problem is a crash in the daemon responsible for managing NSURLSession background sessions. Do you see any crash reports for
nsurlsessiond
?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi eskimo,


So what do you think the proper response would be to this type of error? Should we invalidate the session with [urlSession invalidateAndCancel]?


If so, should we wait a period before restarting the transfers?


We seem to get this error frequently on iOS 11 when a user moves from a captured network (like at Starbucks) back to a home network and opens our app.

So what do you think the proper response would be to this type of error?

I’m reluctant to suggest anything without knowing more about the cause.

We seem to get this error frequently on iOS 11 when a user moves from a captured network (like at Starbucks) back to a home network and opens our app.

Does that then yield a

nsurlsessiond
crash report?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

We don't have access to the client devices to check for crash reports outside of our app. We do pop up an alert message with the error when this occurs. Clients have sent us screen shots of this so we know it's this exact error.


I may be able to check one of our tester devices the next time this happens and provide more detail and a crash log if present.


In the mean time I did make the change to trap the error, invlidate the session and restart the transactions. I will post an update once we determine if this helped or not.

We do pop up an alert message with the error when this occurs.

It would help if this alert asked the user to take a sysdiagnose log at this point. That should contain a bunch of useful info as to what went wrong.

You can learn more about sysdiagnose logs on our Bug Reporting > Profiles and Logs page.

I may be able to check one of our tester devices the next time this happens and provide more detail and a crash log if present.

Cool. Make sure to grab the sysdiagnose at the same time.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Quinn,


We are facing a similar issue. Once the urlsessiond crashes, no new requests seem to go through.

Shouldn't restarting the device launch the daemon again or can you suggest a way to restart the crashed daemon.


Best,

Rahul

If

nsurlsessiond
crashes, it should restart automatically. Either way, a crash in
nsurlsessiond
is always bugworthy, so if you’re seeing this you should definitely file a bug about ti.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Quinn,


Thanks for getting back to me. Its looks like once the customer runs into this issue, no new background upload tasks go through. We ask customers to restart the device, reset network settings, force quit the app but that doesn't help all the time. We can't file a bug as we are not being to reproduce this at our end but a few of users are running into this now.


Could it be related to number of simultaneous upload requests? For some users, we might end up enqueing hundreds of upload requests.

Could it be related to number of simultaneous upload requests? For some users, we might end up enqueing hundreds of upload requests.

It’s possible, but my experience is that

nsurlessiond
handles hundreds of requests just fine. While we don’t have a hard limits, I wouldn’t expect you to see any problems until you start enqueuing thousands of requests.

We can't file a bug as we are not being to reproduce this at our end but a few of users are running into this now.

My recommendation is that you ask the customer to provide you with a sysdiagnose log (see our Bug Reporting > Profiles and Logs page) and file a bug based on that. Oh, and installing the Background Networking and Network Diagnostics configuration profiles will result in better info in the sysdiagnose log.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"