Thursday, 15 August 2013

ios - AFNetworking with Unreliable wifi - Detecting / Retrying connections when they timeout -


I am using AFNetworking in my app to connect / download data from a web service. This app has been deployed through enterprise deployment for users at different locations. At one of the places where people use our app, the WiFi network is going down randomly / comes back in a few seconds. In these cases, the request was to try again three times before abandoning the requirement and failed. I have received a lot of effort to do this fine, but there are some problems in detecting network failure. Some code:

  AFHTTPRequestOperation * operation = [[AFHTTPRequestOperation alloc] initWithRequest: request]; [Operation Settlement BlockWithSuit: ^ (FHTPPRQuest Operation * Operation, ID Response Object) {[Self Pars Response: Operation: Cross String]; } Failure: ^ (FHTPPKAEASTA Operation * Operation, NSERR * Error) {[Manually message: Filecode: Error code reason: [NSString stringWithFormat: @ "% @", Error]]; }];   

The error code I am trying to retry is NSURLErrorTimedOut . But I found another log file, indicating failure with the following error: -1003 "No server with specified hostname was found."

I can add this code to my list as well, but I wanted to ensure that I am capturing all the errors and not just displaying them. I am NSURLError .h file was found and found that the following error codes that are obscurely appear because of network failure.

Can someone help me in what situation I get the error and if I can not find any error code? The list is below:

  NSURLErrorCannotFindHost NSURLErrorTimedOut NSURLErrorCannotConnectToHost NSURLErrorNetworkConnectionLost NSURLErrorDNSLookupFailed NSURLErrorResourceUnavailable NSURLErrorNotconnectedToInternet   

thanks,
fast

It looks like you have an error of just doing NSURLErrorDomain With every domain, you can try every failure (except the case where there was no operation canceled). All those cases should be covered in it.

No comments:

Post a Comment