Possible Duplicate:
NSMutableURLRequest timeout doesn't trigger if data starts to load but not webViewDidFinishLoad
I am using a Async HTTP request and setting timeout for my NSMutableURLRequest to 30 seconds and I want to timeout the request within this time.
Problem: Request is not getting timed out withing 30 seconds. It is always taking 90 seconds to timeout. Any solution for this.
Here is my code for connection:
NSMutableURLRequest *myRequest = [[NSMutableURLRequest alloc] initWithURL:myURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30];
[myRequest setHTTPMethod:@"POST"];
[myRequest setHTTPBody:myData];
NSURLConnection *myConnection = [[NSURLConnection alloc] initWithRequest:myRequest deleg开发者_高级运维ate:self];
And I am implementing following delgates:
- (void)connection:(NSURLConnection *)iConnection didReceiveResponse:(NSURLResponse *)iResponse;
- (void)connection:(NSURLConnection *)iConnection didReceiveData:(NSData *)iElementContructionContextData;
- (void)connection:(NSURLConnection *)iConnection didFailWithError:(NSError *)iError;
You can set your time for timeOutSeconds like this:-
[myRequest setTimeOutSeconds:1000];
Set timeOutSecond according to yourself.
精彩评论