Reputation: 452
I have an app with 100k+ users that connects using a SOAP web service. Everything works fine for most users except sometimes using NSURLConnection I keep getting the error:
Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo=0xac16c70 {NSErrorFailingURLStringKey=https://mail.scripps.org:443/ews/Exchange.asmx, NSErrorFailingURLKey=https://mail.scripps.org:443/ews/Exchange.asmx, NSLocalizedDescription=The network connection was lost., NSUnderlyingError=0x133b0eb0 "The network connection was lost."}
This only happens for certain servers. The servers have NTLM authentication which works 95% of the time but for some reason I'm getting the error and I have no idea why.
Any help appreciated.
Upvotes: 1
Views: 3967
Reputation: 696
This Question also identified the problem I was having. Instead of soap, I'm using jsonrpc.
The solution was simple. I needed:
[myMutableURLRequestObject setHTTPMethod:@"POST"];
Upvotes: 2
Reputation: 57179
Network connection failures happen, you just need to handle them gracefully. One solution may be to retry the connection 1 or more times until it succeeds after you are sure there is a network connection. Rough example below:
if([error domain] == NSURLErrorDomain &&
[error code] == NSURLErrorNetworkConnectionLost &&
retryCount < kMaxRetryCount)
{
[self retry];
++retryCount;
}
Upvotes: 0