Question

Ok firstly if I use a NSURLReuqest(non mutable) as following, the the connection do timeout accordingly to what was set. The weird thing is why does the NSLog always read 0?

self.requestURL = [NSURLRequest requestWithURL:[NSURL URLWithString:requestString]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
NSLog(@"request timeOutInterval:%d", self.requestURL.timeoutInterval); // always 0

Next, I do something like this and the timeoutInterval does not get set.

self.requestURL = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:requestString]] autorelease];
[self.requestURL setTimeoutInterval:20];
NSLog(@"request timeOutInterval:%i", self.requestURL.timeoutInterval); // same thing always 0 here.

EDIT. I am using %f to log the timeoutInterval property now and both reads 20.000. But the real problem is why was my my NSMutableURLRequest not firing the - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error delegate call back method when it reaches the timeoutInterval(20s). Instead it is only timed out at around the 75s. Even longer than the default of 60s...

Even if I remove the [self.requestURL setTimeoutInterval:20]; line, the connection still timeout at 75s.

I have tried

self.requestURL = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:requestString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0] autorelease];

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top