IPhone SDK: URL request not disconnected

I am having a problem with a network request, which should be a timeout, but the method is not being 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

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

But after 4 minutes the error message is not displayed. Does anyone know why this could be?

+3
source share
2 answers

An Apple spokesman revealed that SDK 3.0 and later provide a minimum timeout (you guessed it) of four minutes:

https://devforums.apple.com/thread/25282

If you try to set the timeout value to less than 240 seconds, it will be clamped to 240. If you need a shorter timeout, I voted for the St3fan solution.

+2

- http- NSURLConnection, NSTimer, NSURLConnection, , .

, , . Async (runloop) - 99,9% iPhone.

+3

Source: https://habr.com/ru/post/1737551/


All Articles