我在Amazon S3中使用Swift从我的iOS应用程序中异步下载大约400个文件,但有时我会收到其中几个文件的错误。最大文件大小约为4 MB,最小文件大小为几KB(
)错误是可选的(错误域= NSURLErrorDomain代码= -1001"请求超时。" UserInfo = {NSUnderlyingError = 0x600000451190 {错误域= kCFErrorDomainCFNetwork代码= -1001"(null) " UserInfo = {_ kCFStreamErrorCodeKey = -2102,_kCFStreamErrorDomainKey = 4}},NSErrorFailingURLStringKey = https://s3.us-east-2.amazonaws.com/mybucket/folder/file.html,NSErrorFailingURLKey = https://s3.us-east-2.amazonaws.com/mybucket/folder/file.html,_ kCFStreamErrorDomainKey = 4,_kCFStreamErrorCodeKey = -2102,NSLocalizedDescription =请求超时。 })
我该如何预防?
答案 0 :(得分:0)
尝试增加超时时间:
let urlconfig = URLSessionConfiguration.default
urlconfig.timeoutIntervalForRequest = 300 // 300 seconds