I am calling an API in ASIFormDataRequest
with synchronous method and its returning me time out error on each time, logged this error `Error Domain=ASIHTTPRequestErrorDomain Code=2 "The request timed out" time out seconds set to 10s, some time it shows me this error before 10s.
But most strange is that when I changed to Asnychronous it start working fine. I know that Synchronous block every thing until it gets response and Asynchronous don't block but what are other ways to make different both of them and why this happen in my case. Here below is my code of what I am doing. Kindly suggest me or guide me why this is happen. Looking for response thanks in advance.
NSString *finalStrUrl = [NSString stringWithFormat:@"SomeAPI"];
ASIFormDataRequest *formRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:finalStrUrl]];
[formRequest setTimeOutSeconds:10];
[formRequest setRequestMethod:@"GET"];
[formRequest setAllowCompressedResponse:NO];
[formRequest setDefaultResponseEncoding:NSUTF8StringEncoding];
if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
[formRequest setShouldContinueWhenAppEntersBackground:YES];
endif
[formRequest setDelegate:self];
[formRequest startAsynchronous];
Note: This all happening in cellular Connection.