I am using this snippet to get data from an url .
Approximately 3 Out of 10 machines fails, but in rest 7 machines download goes fine .
I am getting following error .
Any ideas ? Thanks in advance ...
Code:
-(int) GetData : (NSString *) urlstr : (NSData **) bufferdata
{
int retcode =0;
NSError *errorobj = nil;
NSHTTPURLResponse *httpresponse;
NSData *buffer;
@try
{
retcode = 0;
NSLog(@"url string:%@\n",urlstr);
NSURL *urlobj = [NSURL URLWithString: urlstr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlobj cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0];
[request setValue:@"close" forHTTPHeaderField:@"Connection"];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[urlobj host]];
buffer = [NSURLConnection sendSynchronousRequest:request returningResponse:&httpresponse error:&errorobj];
self->httpStatusCode =[B] [httpresponse statusCode];[/B]
[B]NSLog(@"Http response status code: %i: Description:%@\n",self->httpStatusCode,[NSHTTPURLResponse localizedStringForStatusCode:self->httpStatusCode]);[/B]
if(self->httpStatusCode == 200)
{
*bufferdata = buffer;
isconnectionSuccess = TRUE;
}
else {
*bufferdata = nil;
isconnectionSuccess = FALSE;
retcode = 1;
}
//errorobj will be set to some only if intended response is received
if (errorobj)
{
retcode = [errorobj code];
NSLog(@"Error Description: %@\n", [errorobj localizedDescription]);
isconnectionSuccess = FALSE;
}
}
@catch (NSException *exp) {
NSLog(@"GetData: Exception occurred: %@ :reason: %@\n", [exp name],[exp reason]);
retcode = ERROR_FAILURE;
}
return retcode;
}
Approximately 3 Out of 10 machines fails, but in rest 7 machines download goes fine .
I am getting following error .
Code:
Http response status code: 0: Description:server error
Error Description: Could not connect to the server.
Any ideas ? Thanks in advance ...
Last edited by a moderator: