Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLErrorDomain Code=-997 "Lost connection to background transfer service"

I am using NSURLSession to download some mp3 files and store them in the device. Everything works fine but sometimes out of the blue, the app crashes and i get this weird error saying NSURLErrorDomain Code=-997 "Lost connection to background transfer service". It does not happen alot but when it does it just messes up the whole app, like when i launch the app the next time all the download tasks are messed up and i just have to rebuild the application on the device to get it to work again. Note that i only get this error since using Xcode 6 and ios8, even though I'm not sure its is related to ios8 or not.

This is the complete error description:

Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service" UserInfo=0x178664100 {NSErrorFailingURLKey=http://XXXXXXXXXX.mp3, NSLocalizedDescription=Lost connection to background transfer service, NSErrorFailingURLStringKey=http://XXXXXXXXXXX.mp3}
like image 370
Rashid Avatar asked Oct 08 '14 19:10

Rashid


Video Answer


1 Answers

My error was that I used a dataTaskWithRequest instead of uploadtaskWithRequest or in your case downloadtaskWithRequest. Obviously a datatask can't run in the background and get's killed.

like image 133
Caro Avatar answered Sep 28 '22 20:09

Caro