I've noticed recently, that my code, that uses AFNetworking (latest version from master branch) stopped working properly under iOS 6. Here's my code:
httpClient = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:baseURL]];
httpClient.operationQueue.maxConcurrentOperationCount = 1;
where httpClient
is a class variable.
Next, I'm creating a request:
NSMutableURLRequest *signInRequest = [httpClient requestWithMethod:@"POST" path:@"/user/register" parameters:dataToSend];
signInRequest.timeoutInterval = 15.0;
signInRequest.cachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
AFJSONRequestOperation *signInOperation = [AFJSONRequestOperation JSONRequestOperationWithRequest:signInRequest success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON)
{
// Blah
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON)
{
// Blah
}];
[httpClient enqueueHTTPRequestOperation:signInOperation];
All the other requests are constructed similarly. The first enqueued operation works well, I can get into success handler block. However, next calls to other requests are finished with fail handler and request timeout
error, no matter how big is timeout value I choose.
I have done the same calls using plain NSURLConnection
, writing a tons of code :), with success, requests were processed properly.
I switched to iOS 5 device, and the code above works fine.
I switched to 3G connection (iOS 6), and the code above works.
It seems like I have this problem only on WiFi connections (except the case when I'm in the same subnet with my REST server.)
Any thoughts on this?
Thank you in advance.