Iphone – ASIHTTPRequest time out

asihttprequestiphonetimeout

Hello
I am sending some values to the server using ASIHTTPRequest. All works fine until yesterday that the requestFinished didnt work. (when the app send the request on the server an activity indicator and a new view added to the main view and when the request finished is removing the views). I added requestFailed to test if is failed and I get this error:

[3438:207] Error Domain=ASIHTTPRequestErrorDomain Code=2 "The request timed out" UserInfo=0x5ad25c0

Its weird because the same code was working fine yesterday. I am sure that they didnt make any changes on the server's side.

this is the code:

- (IBAction)convert:(id)sender{

//Get the email from the textfield
NSString *email1 = email.text;

//Save the last used email to load it on the next app launch
[[NSUserDefaults standardUserDefaults] setValue:email1 forKey:@"email"];

//Get the current URL from webview
NSString *currentURL= webView.request.URL.relativeString;

lbl.text = currentURL;

//Count the length of Label
int strL= [lbl.text length];

//The url that the requests will be send.
NSURL *url = [NSURL URLWithString:@"the website"];

//Indicator and its view are loading on the screen
[ind startAnimating];
[self.view addSubview:indView];


//ASIHTTPRequests   

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

NSString *watch = [lbl.text substringWithRange:NSMakeRange(23,strL-23)];
NSString *link = [NSString stringWithFormat:@"http://youtube.com/%@",watch];

[request setShouldRedirect:YES]; 
[request setPostValue:watch forKey:@"url"];
[request setPostValue:email1 forKey:@"email"];
[request setPostValue:format forKey:@"format"];
[request setPostValue:quality forKey:@"quality"];
[request setDelegate:self];
[request startAsynchronous];

NSLog(@"%@ %@ %@ %@",watch,email1,format,quality);

click=NO;

}
and this is the requestFinished:

- (void)requestFinished:(ASIFormDataRequest *)request{
NSString *responseString = [request responseString];
NSLog(@"%@",responseString);
NSLog(@"%@",lbl.text);
NSLog(@"requested finished");
[ind stopAnimating];
[indView removeFromSuperview];
[setView removeFromSuperview];

}

Best Answer

Did you try to increase the timeout value on the request? By default it is 10 seconds, you can make it larger by doing this right before the startAsynchronous call:

[request setTimeOutSeconds:60];
Related Topic