0

i am creating an object of AFHTTPRequestOperationManager *manager

    NSString *BaseURLString = @"http://192.168.1.202:81//CredentialsModule/CredentialService.asmx/details";
   AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager  manager];
   [manager POST:BaseURLString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog(@"Success: %@", responseObject);
    NSDictionary *jsonDict = (NSDictionary *) responseObject;
    NSString *products = [jsonDict objectForKey:@"d"];
    NSLog(@"pro %@",products);

    NSString *newString = [NSString stringWithFormat:@"%@",products];
    NSData* data = [newString dataUsingEncoding:NSUTF8StringEncoding];

    NSError* error;
    id jsonObjects = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
    NSLog(@"user id %@",jsonObjects);


    [self.navigationController pushViewController:CategoryViewController animated:YES];

   } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

     NSLog(@"\n Error2: %ld",(long)operation.response.statusCode);
     NSLog(@"\n Error2: %@",  operation.responseString);

}];

suppose i am calling above web service and my session is timeout.So,i want to know is there any chance to identify session timeout before calling the service in afnetworking 2.0. Please don't try to run web service it won't work because its on local server !!

  • Logically, timeout is detected after N seconds of no response. It is better to check `NSError` `code` and `domain` properties to identify a timeout. The `code` should be `kCFURLErrorTimedOut ` if I'm not mistaken. – vokilam Feb 18 '14 at 10:57
  • yes,i have check NSError it return this Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: internal server error (500)" UserInfo=0x1095abbd0 – user2609079 Feb 18 '14 at 13:42
  • {AFNetworkingOperationFailingURLResponseErrorKey= { URL: http://192.168.1.202:81/PatientModule/PatientService.asmx/GetAllLisPatientCaseDetail } { status code: 500, headers { "Cache-Control" = private; "Content-Length" = 961; "Content-Type" = "application/json; charset=utf-8"; Date = "Tue, 18 Feb 2014 13:18:22 GMT"; Server = "Microsoft-IIS/7.5"; "X-AspNet-Version" = "4.0.30319"; "X-Powered-By" = "ASP.NET"; jsonerror = true; } }, NSLocalizedDescription=Request failed: internal server error (500), – user2609079 Feb 18 '14 at 13:42
  • NSErrorFailingURLKey=http://192.168.1.202:81/PatientModule/PatientService.asmx/GetAllLisPatientCaseDetail} – user2609079 Feb 18 '14 at 13:42
  • this is the whole error which i have got from NSError. If you can find anything in that error,please share with me..thanks – user2609079 Feb 18 '14 at 13:43
  • It's not a timeout error. This error means, that your server script has crashed. Please, add details to your answer description in future. If you want to simulate timeout refer to http://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error – vokilam Feb 18 '14 at 13:46

0 Answers0