iPhone SDK: URL request not timing out.

Posted by codemercenary on Stack Overflow See other posts from Stack Overflow or by codemercenary
Published on 2010-03-18T16:17:26Z Indexed on 2010/03/18 16:21 UTC
Read the original article Hit count: 451

Filed under:
|

I am having a problem with a network request that should timeout, but the method is not called. The request is as follows:

#define kCONNECT_TIMEOUT 20.0

request = [NSMutableURLRequest requestWithURL: aUrl];
[request setHTTPMethod: @"POST"];
postData = [jsonData dataUsingEncoding:NSASCIIStringEncoding];
[request setHTTPBody:postData];
[request setValue:@"text/xml" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; 
[request setCachePolicy:NSURLCacheStorageAllowed];
[request setTimeoutInterval:kCONNECT_TIMEOUT];
self.connection = [NSURLConnection connectionWithRequest:request delegate:self];
assert(self.connection != nil);

This should get a callback to

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)_error 

But after 4 minutes not error message is displayed. Anyone know why this might be?

© Stack Overflow or respective owner

Related posts about nsurlconnection

Related posts about timeout