0

I'm using AFNetwrorking. After sending request sometimes i get

Error: Error Domain=NSURLErrorDomain Code=-1005 "Network connection is lost."

Even when internet is available sometimes it randomly occurs. The second or the third try the request works.

Is there any way to restart this request if the first one fails. I mean is there a parameter in operationManager to set the number of tries?

here is how im using AFNetworking:

   AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager];
    operationManager.requestSerializer = [AFJSONRequestSerializer serializer];
    operationManager.responseSerializer = [AFJSONResponseSerializer serializer];

    operationManager.responseSerializer.acceptableContentTypes = [operationManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];

[operationManager POST:URL
                parameters:parameters
                   success:^(AFHTTPRequestOperation *operation, id responseObject) {
  ......
Jenya Kyrmyza
  • 327
  • 1
  • 5
  • 16
  • 1
    this is well known networking issue ...you can check here ....http://stackoverflow.com/questions/25372318/error-domain-nsurlerrordomain-code-1005-the-network-connection-was-lost – Bhavin Bhadani Feb 12 '16 at 11:01
  • @EICaptain seems like that issue was on ios8 emulator, but i have it on the real device – Jenya Kyrmyza Feb 12 '16 at 11:22
  • no its not a simulator issue...Ya sometimes it works on reset content settings but its not solved problem fully ...check this link and check a post of matt .......https://github.com/AFNetworking/AFNetworking/issues/2314 – Bhavin Bhadani Feb 12 '16 at 11:31
  • Unfortunately, because this appears to be a bug in the underlying Foundation URL Loading System, there is no real way for AFNetworking to work around this issue. – Bhavin Bhadani Feb 12 '16 at 11:33
  • @EICaptain ok. thanks man. I will try to call the request twice – Jenya Kyrmyza Feb 12 '16 at 12:18

0 Answers0