Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebSocket is closed before the connection is established [duplicate]

I'm using JavaScript and the Union platform How would I go about diagnosing this problem? Many thanks.

like image 597
user1144112 Avatar asked Sep 19 '12 02:09

user1144112


2 Answers

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
like image 90
danishprakash Avatar answered Sep 18 '22 17:09

danishprakash


If you go to http://jsbin.com/ekusep/6/edit and view the JavaScript console you'll see the 'WebSocket is closed before the connection is established' logged. I've 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 it's had a chance to actually connect.

like image 28
leggetter Avatar answered Sep 18 '22 17:09

leggetter