javascript – What does WebSocket is closed before the connection is established mean?

javascript – What does WebSocket is closed before the connection is established mean?

If you go to http://jsbin.com/ekusep/6/edit and view the JavaScript console youll see the WebSocket is closed before the connection is established logged. Ive tested this in Chrome.

In this code what it means is that ws.close() was called (by user code) before the connection was even given a chance to be established.

So, the cause of this error is if code attempts to close the WebSocket connection before its had a chance to actually connect.

For anybody else coming in to find an answer, apart from what @leggetter has mentioned above, in my case, it turned out that I was missing the port number while establishing a connection. I was using socket.io if that helps.

http://websocket.service:8000

javascript – What does WebSocket is closed before the connection is established mean?

Leave a Reply

Your email address will not be published.