Good Morning, wondering if i can get some help regarding nsurlsession behaviour on the case mentioned in the title.
I'm trying to enqueue several upload tasks to a background session created from configuration:
discretionary=false
sessionSendsLaunchEvents=true
waitsForConnectivity = true
The app delegate is handling the finish of all tasks with
handleEventsForBackgroundUrl
The session delegate is implemented with:
didCompleteWithError
didSendBodyData
DidFinishEventsForBackgroundSession
The NSURLSessionUploadTask tasks are being enqueued to the background session with task.resume(). Each NSURLSessionUploadTask is attached with a NSURLRequest with a body content populated from a file (in device memory - app documents folder).
Each file is around 20-odd Mb.
This all works fine if i do a couple of tasks. When i want to attach dozens of tasks to the background session nsurlsession connection gets invalidated and terminated (we ultimately want up to hundreds... but i do understand nsurlsession should cope with up to thousands).
Error (639) (CFNetwork): BackgroundSession connection to background transfer daemon interrupted
Error (639) (CFNetwork): BackgroundSession connection to background transfer daemon invalidated
The daemon does restart but the upload tasks will then all fail with:
Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service"
The nsurlsessiond daemon does not warn of any crash or warning that is about to crash but then again i can't be sure given that the log probably only makes sense to the team responsible for nsurlsession dev. An example timeframe log of nsurlsessiond around a connection invalidated/terminated is attached.
FYI and completion i've tested in different xcode versions (12.3,12.5) and different iOS versions.
Is there any limitations on size of tasks when enqueuing to background session N (dozens) number of tasks ? Am i missing any major handling of nsurlsession/configuration parameter?
Happy to provide more info if necessary.
Best Regards