When I open the app from background I need to hit server to get some data. When I'm doing so I am getting an alert as follows:
"Request timed out" (nserror's localised description)
I'm on wifi and my internet as well as my server are fine.
This is not happening every time but happening frequently. Here is my code:
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:myUrlString]];
NSURLConnection *conn=[[NSURLConnection alloc]initWithRequest:request delegate:self]; //sending request for data self.dataConnection=conn; [conn release];
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@"Network Exception" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
What am I doing wrong and how can I fix this?
NSURLRequest *lRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:link] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
even i've used the above line instead of
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:myUrlString]];
but found nothing different . Still my request is getting timed out. Why is it getting timed out even when my server aswell as wifi (internet) are fine.?? Thanks in Advance....
From here you can get the guidance...NSURLConnection timeout?