Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECONNRESET with version 1.0.10 #150

Open
gsferreira opened this issue Oct 31, 2014 · 10 comments
Open

ECONNRESET with version 1.0.10 #150

gsferreira opened this issue Oct 31, 2014 · 10 comments
Assignees

Comments

@gsferreira
Copy link

Hi,

I'm using websocket 1.0.8 in a project with success, but when I try to upgrade it to 1.0.10 I lose the connection, receiving the following error:

[Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

There's anything related to the upgrade that I'm missing?

@theturtle32
Copy link
Owner

Interesting. That shouldn't be happening, obviously. I'm actually a little bit puzzled about how it even can happen. WebSocket-Node is using Node streams-1 semantics, meaning that we never actually call read on the socket. We listen for data events.

Can you provide any more context or information about when this error is happening, under what circumstances, etc? Does it happen during the handshake? Is it after the connection has been established for a while?

@theturtle32
Copy link
Owner

For what it's worth, that means that the connection was lost anyway, and there's nothing that could be done to recover from that. There's actually not a strong use case for handling the error events from WebSocketConnection, since there's nothing you can really do about them. In fact, if there are no listeners for the error events, WebSocketConnection will not emit them at all, because the default node behavior is to stop the program and print a stack trace, and these aren't important enough to warrant crashing your program over. Whenever there is a socket error, there will be a close event emitted with reason code 1006 (abnormal close). Your program can and should handle these exactly the same way it would handle a normal close caused by the user exiting their browser. The close code and information from the error events can be logged if desired for debugging and informational purposes, but other than that, I can't think of a good use case for doing anything else with them.

@gsferreira
Copy link
Author

I'm using this node package that uses websocket-node: https://www.npmjs.org/package/signalr-client

I'm trying to upgrade websocket-node because I need to communicate with a service that requires client certificates, and with websocket-node 1.0.8 I can't set the pfx at Request options.
Basically now I can add the following parameters:

            client: new WebSocketClient({
                tlsOptions: {
                    rejectUnauthorized : false,    
                    pfx : fs.readFileSync('mycert.pfx'),    
                    passphrase : 'mypassword',
                }
            }),

Thank you for the quick response

@theturtle32
Copy link
Owner

I'm still interested in when this error is happening. Is it preventing you from even successfully connecting at all? Does it happen some time later after the connection has been working for a little while?

@gsferreira
Copy link
Author

I'm connected to the server and I receive the response, but the connection throws that error.

You can see here the service log:

debugger listening on port 5858
Express server listening on port 1337
waiting...
Websocket bound
Client State Code:  2
Client State Description:  connecting
Websocket reconnected
Connection Lost:  { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRE
SET', syscall: 'read' }
Websocket Retrying:  { inital: true, count: 0 }
Websocket disconnected
Websocket reconnected

@plato-cambrian
Copy link

I'm getting a similar problem on Windows 7 and node 0.10.30.

I get Error: read ECONNRESET as soon as I try and connect to my remote server.

I don't yet know if this is a configuration problem or bad implementation on the server.
So far I have seen failures with both websocket@1.0.8 and websocket@1.0.14.

I don't know what I can do to troubleshoot further.

@theturtle32
Copy link
Owner

@plato-cambrian are you using WebSocket-Node directly, or via a library that uses it? Can you provide information about what is failing and how?

@theturtle32
Copy link
Owner

Any updates on this?

@plato-cambrian
Copy link

@theturtle32 turned out that my problem was simply I was trying to connect to a W3C Websocket server with require('websocket').client, oops!

@haches
Copy link

haches commented Dec 9, 2015

Hi,

I experience a similar problem as described in the original bug report:

[Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read'

What I'm doing:

I connect via WebSocket to a Docker container, I start the container, read it's output on "data" events.
When the container is done it closes the websocket connection. In most cases, that's a normal "close" event (closeReasonCode 1000).

Every now and then (let's say 1 out of 5 times), however, the connection is not cleanly closing and instead an "error" event is triggered (with the ECONNRESET error). At this point the container is already done and has produced all its output. So I assume it was intending to close the connection.

Unfortunately, I can't determine the root of this behavior. Any idea how I could close in on that?

Using: websocket 1.0.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants