我之前从未遇到过这个问题,但有时当我从我的服务器请求数据时(大约10%的时间)我从未收到响应(甚至不是标题!)并且请求超时。我使用的是networkQueue,它的设置就像这样
//when initializing
networkQueue = [[ASINetworkQueue queue] retain];
networkQueue.maxConcurrentOperationCount = 5;
networkQueue.delegate = self;
networkQueue.requestDidReceiveResponseHeadersSelector = @selector(request:DidReceiveHeaders:);
networkQueue.requestDidFinishSelector = @selector(NetworkQueueRouter:);
networkQueue.requestDidFailSelector = @selector(requestDidFail:);
我用这个方法初始化请求
-(void)sendRequest:(NSURL *)url withParams:(NSDictionary *)params andUserInfo:(NSDictionary *)info{
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
request.delegate = self;
NSString *jsonString = [params yajl_JSONString];
[request setPostValue:jsonString forKey:@"json"];
request.timeOutSeconds = 30;
if (info != nil) request.userInfo = info;
[networkQueue addOperation:request];
[networkQueue go];
}
使用iPhone或iPhone模拟器时,我只遇到此问题。有时候请求是永久性的,我会用相同的请求检查我的浏览器,当iPhone仍在请求时,我会立即从浏览器得到响应。
以前有没有人经历过这个?