Reputation: 3920
In my app the user has the possibility to download many files at once. Those files are about 2MB each.
As the user can choose as many files at once as he likes, I set my operationQueue
to only allow 2 concurrent operations.
Here's how I set up my session manager:
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.timeoutIntervalForRequest = 60;
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
[manager.operationQueue setMaxConcurrentOperationCount:2];
self.urlSessionManager = manager;
Now the downloads begin. But if the download of ALL files takes longer than the timeout I specify, ALL other NSURLSessionDownloadTask
s (so also those who didn't even start) fail. So it seems as if the timeout stars counting the second I create the downloadTask and not when they really start to make their request?
As I have a queue, I'd expect the timeout to start counting as soon as it's the downloads tasks turn to download?!?
What do I have to change in order to be able to really let the user download all those files at once?
Upvotes: 2
Views: 489
Reputation: 10407
Basically, if the request never starts (and thus never requests any data), then incoming data won't ever reset that timer, which means the task gets cancelled after 60 seconds. That behavior is somewhat non-obvious, and is probably worth filing a bug about.
You can work around this by creating your own URL protocol that reissues the requests in a session with no timeout and no connection limit (so that your code knows when the request actually starts) and then managing the timeouts yourself.
Upvotes: 1