一旦我向服務器發送請求(通過NSURLConnection
sendSynchronousRequest
方法),服務器在大約2秒鐘內收到它,它會在3-5秒內處理併發迴響應。但是,我只能在30-35秒內收回迴應。這種延遲使我們的溝通非常緩慢。iphone延遲服務器響應
即使異步API獲得延遲響應。
此前,一切工作正常,客戶端在10秒內獲得響應。 其他人有這個問題?可能是什麼原因?
編輯 這裏是Wireshark
分析的截圖:
Link以更好的形象
我應該如何看什麼包說什麼..爲什麼它延遲?
EDIT2 下面是代碼:
NSHTTPURLResponse *response=nil;
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:nsURL] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:180.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setTimeoutInterval:180.0];
[theRequest setHTTPBody:[[NSString stringWithFormat:@"%@",sdata] dataUsingEncoding:NSASCIIStringEncoding]];
NSError *error= nil;
NSData *result = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
if (error) {
NSLog(@"error sending synchronous request: %@", error);
}
NSLog(@"request completed with code:%d",response.statusCode);
將代碼爲更好地瞭解 – iPatel
@iPatel:看到編輯 –
檢查網絡......可能是網絡烏爾issueee – iPatel