2011-05-17 44 views
0

我一直在使用ASIHTTPRequest作爲應用程序,但它給我錯誤topSecretFetchFailed方法5出10個請求,不知道如何處理它,難道ASIHTTPRequest不夠穩定?iOS中的ASIHTTPRequest

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

編輯:

這是我的代碼或方法,該方法被調用每個請求。 MARKET_INDEXES_URL其具有「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]; 
} 

,這是失敗的處理程序

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

回答

2

你需要的是一些報告的回覆細節。沒有這個,你在黑暗中診斷。把這個放在你的失敗句柄中:

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

@丹謝謝你的幫助。 – Demones 2011-05-18 04:20:16

+0

@Dan我在我的失敗處理程序中接收statuscode = 0和statusmessage = null,不知道發生了什麼。 – Demones 2011-05-18 04:47:44

+0

@Smin - 我想我們需要看到更多的代碼。 – 2011-05-18 12:00:39

0

ASIHTTPRequest是穩定的。您可能會因爲網絡關閉或服務器響應時間太長而出錯。

您應該嘗試將ASIHTTPRequest屬性numberOfTimesToRetryOnTimeout更改爲適合您的內容。

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

感謝您的回覆,我的網絡非常穩定。我需要嘗試使用此屬性。 – Demones 2011-05-17 10:08:25