Error: received error: [57] Socket is not connected - iOS 10
Asked Answered
J

4

30

I just updated to Xcode 8 and iOS 10.

After creating a build, I'm running into an error which I think is contributing to some data not getting fetched.

I don't know where to go from here, but it appears to be related to http calls somehow. Either way, I don't like the looks of these errors and need to get to the bottom of things.

In the log I get:

[] nw_connection_write_close 9 Connection is not ready, sending error callback
[] __tcp_connection_write_eof_block_invoke Write close callback received error: [57] Socket is not connected

What do these errors mean and how might I go about finding where to look?

Are these error reports related to the depreciation of NSURLConnection as of iOS 9?

Juryman answered 14/9, 2016 at 0:54 Comment(9)
If you don't know what point in your code is triggering the error message, you might try stepping through it with breakpoints.Donoho
Updated to Xcode 8 and iOS 10 too. I'm also seeing precisely these errors, and am also experiencing some http issues. Specifically, a completion url configured in my app is no longer being called (works on iOS 9). If you make any headway, please update! Looking too, but this is 3rd party code and I'm not making much progress... Stepping through didn't reveal much either. This happens after the view is laid out, that's all I've identified so far.Joellejoellen
The same error happened to me while I was having some issues using NSURLSession to do an uploadTask but it went away when I was successfully sending data. I never used NSURLConnection.Adalai
Same with me, I'm using Firebase in my appPew
Same happens to me too with iOS10.0.1. It seems that when the socket connection drops, the corresponding error delegate methods: - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(nullable NSError *)error; or with old NSURLConnection: - (void) connection:(NSURLConnection*) connection didFailWithError:(NSError*) error. I have tested this with both old and new NSURLSessionStreamTask. The issue in my case was raised when reading from InputStream - it returns 0 bytes.Elaterid
Same error happens to me also with iOS 10.0.1 and Xcode 8.0. @JThora, have you find any solutions?Trioxide
Hello JThora, Have you get any solution? I am facing the save error while sending XML request using NSURLConnection classTrioxide
Hey guys, JThora and @Punita, did you have any luck with it? I'm experiencing this when app goes background, socket drops connection. Even if background mode is active for the app.Theologue
Hey @0xNSHuman, did you solve the problem? I have the exact problemGaffney
R
14

We got the same error. The problem was that we used background without having the key in the info.plist file (see image below).

enter image description here

After we fixed this, the error message disappeared. Instead we got a lot of log messages, which you can turn off (see Hide strange unwanted Xcode 8 logs).

I hope this helps.

Rebarebah answered 30/9, 2016 at 14:0 Comment(1)
There's definitely something to this error message that doesn't involve background modes. I get it in foreground as well. However, I will note that despite seeing this error message, I don't detect any adverse behavior. I'm wondering if this is just log noise from Xcode? Wouldn't be the first time.Fortyish
K
3

I clean the project and the problem solve for me command+shift+k

Knitting answered 28/12, 2016 at 8:8 Comment(0)
A
2

Add this line after Token Authorization,

request.addValue("application/json", forHTTPHeaderField: "Content-Type")

It works for me.

Analog answered 27/9, 2023 at 10:48 Comment(1)
Wow yes, the error seems to be gone with it.Godfrey
F
1

My best guess is that these error messages have to do with the server you are trying to reach, as opposed to your usage of NSURLConnection

I began experiencing these messages in iOS 11 (and the corresponding Xcode versions) when testing my program locally.

I noticed that I only saw these errors when testing against my local Django server. When pointing the app a normal, appropriately configured webserver, I would not see them.

Some related reading suggests (but not definitively) that this message might have to do with contacting servers which do not have SSL configured (properly, or at all). This would correlate with my experiences.

Anecdotally, I see these errors constantly when testing on my local server, however, I have yet to notice a single instance where this has resulted in adverse behavior, such as a failed request, and in fact, my response handlers don't even think that a proper HTTP error has taken place.

My assessment of all this information is that this is typical Xcode noise resulting from the underlying network APIs fighting with poorly configured webserver stacks.

Fortyish answered 5/6, 2018 at 21:40 Comment(1)
Very insightful, this makes a lot of sense to meJuryman

© 2022 - 2024 — McMap. All rights reserved.