Yun*_*Yun 5 timeout httpclient ios afnetworking afjsonrequestoperation
我正在使用AFJSONRequestOperation上传图片.
在上传图像数量的情况下,某些请求因超时错误而失败.
我试过了
AFJSONRequestOperation *operation = ...
[operation start];
Run Code Online (Sandbox Code Playgroud)
和
AFJSONRequestOperation *operation = ...
[operations addObject:operation];
...
[client enqueueBatchOfHTTPRequestOperations:operations progressBlock:nil completionBlock:nil];
Run Code Online (Sandbox Code Playgroud)
但是,仍然没有运气.
我认为时间计数在创建操作时开始.
那么,我应该为我自己的算法逐个安排请求吗?
值得注意的是,AFNetworking 将创建与系统拥有的资源一样多的 NSOperations 并同时运行它们。问题是应用程序/计算机只能同时建立这么多的网络连接。操作一开始就开始计数。出于所有实际目的,在 iPhone 上您可能不会看到问题,因为运行多个操作的资源较少,但模拟器可以一次运行数百个线程(远远超过最大并发网络连接数)。
我的建议是将并发操作的数量(我认为位于 AFHTTPClient 中)限制为比NSOperationQueueDefaultMaxConcurrentOperationCount允许设备运行尽可能多的资源更合理的数量。