问题
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:
I just ran into similar problem, fixed it by using timeoutIntervalForResource instead of timeoutIntervalForRequest
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfigurationbackgroundSessionConfiguration:bgSessionConfigIdentifier];
sessionConfig.HTTPMaximumConnectionsPerHost = 1;
sessionConfig.timeoutIntervalForResource = 60;
来源:https://stackoverflow.com/questions/20505858/nsurlsessionconfiguration-timeoutintervalforrequest-doesnt-seem-to-work-with-th