NSURLSessionConfiguration timeoutIntervalForReques

2019-05-27 03:35发布

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条回答
淡お忘
2楼-- · 2019-05-27 04:09

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

NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfigurationbackgroundSessionConfiguration:bgSessionConfigIdentifier];
sessionConfig.HTTPMaximumConnectionsPerHost = 1;
sessionConfig.timeoutIntervalForResource = 60;
查看更多
登录 后发表回答