RestKit timeout is ignored

I am calling a web service from my iOS application, which can take up to four minutes. I use RestKit to call and load objects. I find that when requests take a long time, I get a timeout error after ~ 60 seconds. I tried setting the Interval timeout to absurd amounts, but it still expires after ~ 60.

RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:HOSTNAME]; objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; objectManager.client.disableCertificateValidation = YES; //timeout objectManager.client.timeoutInterval = 1000; 

Here is the service call:

 - (void)loadData { NSString *uid = [self retrieveFromUserDefaults:@"login_preference"]; NSString *pwd = [self retrieveFromUserDefaults:@"password_preference"]; if([uid isEqualToString:@""] || [pwd isEqualToString:@""]){ [self stopSpinner]; [self enableUserInterface:YES]; UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Missing Settings" message:@"Please enter your login information in the settings." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; return; } RKObjectManager* objectManager = [RKObjectManager sharedManager]; NSDictionary *params = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:uid, pwd, nil] forKeys:[NSArray arrayWithObjects:@"uid", @"pwd", nil]]; // Load the object model via RestKit [objectManager loadObjectsAtResourcePath:[@"/synchData" appendQueryParams:params] delegate:self]; 

}

I am making a web service call in the background thread - is there something in this design that might cause the problem? I can not imagine how, for example, iOS, not allowing background threads to work for more than 60 seconds? I just can't figure out what the problem is.

Is there a timeout for receiving a response from a server or receiving a WHOLE response from a server? I am returning a potentially very large json response - do I need to return all this within a timeout, or do I just need to get any response from the server within the limit?

+7
source share
2 answers

If I understand your problem, the solution will look like this:

 - (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error 

Therefore, when you have a problem with the timeout interval, it will be caught with this method.

+2
source

I have the same problem, the delegate method requestDidTimeout:(RKRequest*)request never called. Regardless of whether the timeout is set to RKRequest or RKClient.

Protest: When setting the timeout in the request, I see the request NOT observing the set timeout If I have not called [requestObject createTimeOutTimer] .

However, as I noticed in your implementation, you are using 1000 for NSTimeInterval: do you mean 1000 seconds for a timeout? Change to 1 if you mean one second = 1000 ms.

The default timeout for RestKit is 120 seconds, so this is most likely the NSURLConnection timeout.

0
source

All Articles