1

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.

Joe
  • 56,979
  • 9
  • 128
  • 135
VTS12
  • 452
  • 8
  • 22
  • Possible duplicate of [NSURLConnection GET request returns -1005, "the network connection was lost"](http://stackoverflow.com/questions/25797339/nsurlconnection-get-request-returns-1005-the-network-connection-was-lost) – CMash Dec 10 '15 at 11:54

2 Answers2

2

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"];
Community
  • 1
  • 1
C Fairweather
  • 696
  • 4
  • 20
0

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;
}
Community
  • 1
  • 1
Joe
  • 56,979
  • 9
  • 128
  • 135
  • I already do this. For this specific server, the challenge is only being hit once for NTLM anyway. It does however seem to have multiple NSURLAuthenticationMethodServerTrust challenges after the NTLM whereas other servers only have a NSURLAuthenticationMethodServerTrust once. – VTS12 May 13 '13 at 18:07
  • So this happens 100% of the time for the specific server? Or just 5% of the time for that specific server? – Joe May 13 '13 at 18:12
  • 100% of the time for that specific server but 95% of the time in general for all of my users. – VTS12 May 13 '13 at 18:26