I'm using AFJSONRequestOperation to upload the images.
In the case of uploading numbers of images, some requests are failed with the timeout error.
I tried
AFJSONRequestOperation *operation = ...
[operation start];
and
AFJSONRequestOperation *operation = ...
[operations addObject:operation];
...
[client enqueueBatchOfHTTPRequestOperations:operations progressBlock:nil completionBlock:nil];
However, still no luck.
I think that the time count starts when the operation is created.
So, should I schedule the requests one by one for my own algorithm?
Something interesting to note is that AFNetworking will create as many NSOperations as the system has resources for and run them concurrently. The problem is that there are only so many simultaneous network connections the app/computer can make. The count starts as soon as the operation starts. For all practical purposes, on the iPhone you may not see issues since there is less resources to run multiple operations, but the simulator can run hundreds of threads at a time (many more than the max concurrent network connections).
My suggestion is to limit the number of concurrent operations (located in AFHTTPClient I think) to something more reasonable than NSOperationQueueDefaultMaxConcurrentOperationCount
which allows the device to run as many as it has resources for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With