Q:

NSURLConnection Timeout frequently a few seconds after the request

I'm having a weird problem in my app. The NSURLConnection goes frequently to the following delegate method (a few seconds after the request before the timeout occurs): 
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
  if (DEBUG_ON)
      NSLog(@"No connection");
  UIAlertView *popup = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:NSLocalizedString(@"TimeoutError", nil) delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  popup.alertViewStyle = UIAlertViewStyleDefault;
  [popup show];
}

I'm doing all my connections like this:
NSString *dataStr = [NSString stringWithFormat:LOGIN_JSON_TEMPLATE, email, passwd];
NSData *data = [dataStr dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:LOGIN_WS];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [data length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:data];
if (self.loginConnection == nil)
    self.loginConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
else
    self.loginConnection = [self.loginConnection initWithRequest:request delegate:self];

If i'm right there's a default timeout for the request (60 seconds?). I tried to change it but it didn't change anything.
Any idea why?
Thanks in advance.

A:

Try this code:
NSMutableURLRequest *request1 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:1200.0]; 

Instead of 
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];

and you can change timeoutinterval.

