NSURLSessionConfiguration timeoutIntervalForRequest doesn't seem to work with the background session

1.4k views Asked by At

The new timeout property of NSURLSessionConfiguration doesn't seem to work when the session is set to work in background (via backgroundSessionConfiguration call).

Anybody know if that's really the case?

Code snippet:

NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration backgroundSessionConfiguration:bgSessionConfigIdentifier];
sessionConfig.HTTPMaximumConnectionsPerHost = 1;
sessionConfig.timeoutIntervalForRequest = 60;

Do I need to do anything extra for the timeout to work?

1

There are 1 answers

0
JayF On

I just ran into similar problem, fixed it by using timeoutIntervalForResource instead of timeoutIntervalForRequest

NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfigurationbackgroundSessionConfiguration:bgSessionConfigIdentifier];
sessionConfig.HTTPMaximumConnectionsPerHost = 1;
sessionConfig.timeoutIntervalForResource = 60;