5

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 delegate: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;
Community
  • 1
  • 1
Abhinav
  • 37,684
  • 43
  • 191
  • 309

1 Answers1

5

You can set your time for timeOutSeconds like this:-

[myRequest setTimeOutSeconds:1000];

Set timeOutSecond according to yourself.

Gypsa
  • 11,230
  • 6
  • 44
  • 82