开发者

ASIHTTPRequest in iOS

开发者 https://www.devze.com 2023-03-06 16:22 出处:网络
I have been using ASIHTTPRequest for an application but it gives me error in topSecretFetchFailed method 5 out of 10 request, Not sure how to deal with it, Isn\'t ASIHTTPRequest stable enough?

I have been using ASIHTTPRequest for an application but it gives me error in topSecretFetchFailed method 5 out of 10 request, Not sure how to deal with it, Isn't ASIHTTPRequest stable enough?

[request setDidFailSelector:@selector(topSecretFetchFailed:)]; 

EDIT:

This is my code or method which get called in each request. MARKET_INDEXES_URL its static string which has "someurl.com";

- (void)requestData { 
   ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:[NSURLURLWithString:MARKET_INDEXES_URL]];
   [req setDelegate:self]; 
   [req setDidFailSelector:@selector(topSecretFetchFailed:)]; 
   [req setDidFinishSelector:@selector(topSecretFetchComplete:)]; 
   [self setRequest:req]; 
   [self.request startAsynchronous]; 
}

and this is the fail handler

- (void)topSecretFetchFailed:(ASIHTTPRequest *)theRequest { 
   [[NSNotificationCenter defaultCenter] postNotificationName:@"MarketIndexesError" object:nil]; 
   UIAlertView *view = [[UIAlertView alloc] initWithTitle:@"Warning !" message:@"Connect开发者_开发技巧ion error, Please try again" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];   
  [view show]; 
  [view release]; 
  NSLog(@"MarketIndex service Fail: %d %@", [theRequest responseStatusCode], [theRequest responseStatusMessage]); 
} 


What you need is some reporting of the response details. Without that, you're diagnosing in the dark. Put this in your failure handler:

NSLog(@"Fail: %d %@", [request responseStatusCode], [request responseStatusMessage]);


ASIHTTPRequest is stable. You are probably getting error because either your network is down or your server is taking too long to respond.

You should try changing the ASIHTTPRequest property numberOfTimesToRetryOnTimeout to something that suits you.

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:....
request.numberOfTimesToRetryOnTimeout=10;
0

精彩评论

暂无评论...
验证码 换一张
取 消