Background
I am creating a series of requests to grab a chunk of a file. The chunk size stays the same so the number of requests may change depending on which file I am downloading. For smaller files, and thus smaller number of requests I seem to reliably succeed. However once my request chain reaches the 10+ ballpark I start to get an error.
Error
I am getting an error from what appears to be Alamofire.
Error code -999 cancelled.
Looking at other purposed solutions
From the searching I have done it seems that this occurs when either the session manager is deallocated
or another request was kicked off before I received a response from the previous request
.
I made my session manager static, as stated by some other posts to handle the deallocating issue, but I still get this error.
I don't think the next request is being called before the first finishes as my logs seem to be printing out in order and the failure is rather random. I would expect that the requests would overwrite quite reliably.
Is there any thing else that causes this error code to occur?
Additional Logs
NetworkFilesClient.swift:351 - Error downloading chunk URL: MY_URL_HERE,
Range: bytes=29360128-33554432,
Error: Error Domain=NSURLErrorDomain Code=-999 "cancelled"
UserInfo={NSErrorFailingURLKey=MY_URL_HERE,
NSLocalizedDescription=cancelled,
NSErrorFailingURLStringKey=MY_URL_HERE}
What works for me:
sessionManager.session.finishTasksAndInvalidate()
I put this at the end of my response handling. Why? No clue...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.