7

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.

anticyclope
  • 1,577
  • 1
  • 10
  • 26
  • Same thing happening here. I could get it to work by coding the request manually but still using the AF..RequestOperation. AFHTTPClient worked on my home wifi but not through my uni's proxy. – David Lawson Jan 24 '13 at 10:53

1 Answers1

2

It seems you also posted an issue on AFNetworking's github and found the solution yourself :)!

It seems like iOS 6 changes something to TCP implementation or something. I moved server to third-party hosting and it is working now.

For future readers, the issue can be found here.

Tieme
  • 62,602
  • 20
  • 102
  • 156