Error 57 : "Socket is not connected" since iOS 10 - 2

Hi. Guys.


I have a problem in iOS 10 (also iOS 10.1.1)

Our Project has mobileWeb, mobileApp. (this is very similar page)


There are strange issue.

First, I checked mobileWeb using safari browser.

Sometimes, http response is cut. (Html file is cut.)

So, rendered page is so strange and doesn't have data.

So I checked mobileApp using xcode and safari web inspector.

Then, xcode log show like this.

-------

nw_connection_write_close 512 Connection is not ready, sending error callback

__tcp_connection_write_eof_block_invoke Write close callback received error: [57] Socket is not connected

-------


But, there are more strange situation.

I can not catch the error event with below method.

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

(UIWebView) - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error

(WKWebView) - - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error

(WKWebView) - (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error


I guess this issue is related in intranet setting.

Because, my home wifi or LTE is so fine.

Even if use intranet iOS 9 is also fine.

And native app is fine.


So, How can I solve this problem ?

What is different between iOS9 and iOS10 in network ?



Replies

Hey deltaposter,


I opened a thread about the same issue about 3 weeks ago, and I was just about to write a new post in it (url is https://forums.developer.apple.com/thread/67606 ).


I did not manage to resolve the issue yet, however, I'm able to reproduce it in a new project by sending requests to my server.


I know that the system logs you're seeing ("Connection is not ready", "Socket is not connected"..) do not necessarily mean that the request will fail.

However, I get an error callback when the issue happens, either in connection:DidFailWithError: or in the URLSessionDataTask completion handler when using URLSession, saying that "The network connection was lost".


In my case, it only happens over Wifi, never over cellular connection. It seems that the request fails even though it actually received data ; the response status code is 200, and received data may be incomplete, but the connection was terminated before receiving all of the data.