Ws: Error('not opened') on reloading the page

Created on 23 May 2014  路  4Comments  路  Source: websockets/ws

I'm trying to replicate the simple example in the readme. But when i refresh the page i get the following error...

/usr/lib/node_modules/ws/lib/WebSocket.js:187
    else throw new Error('not opened');
               ^
Error: not opened
    at WebSocket.send (/usr/lib/node_modules/ws/lib/WebSocket.js:187:16)
    at /var/lib/cloud9/eventrecorder/server.js:22:7
    at f.digitalRead.readFile (/usr/lib/node_modules/bonescript/index.js:355:13)
    at fs.readFile (fs.js:176:14)
    at Object.oncomplete (fs.js:297:15)

Any suggestions?

Most helpful comment

You can use a callback to catch this error:

ws.send(data, function data(err) {
  if (err) handleError(err);
});

All 4 comments

I've tried it with the code below but the problem remains. Need to check on a stable channel. I've used FF Nightly.

window.onbeforeunload = function(e) {
  ws.close();
};

As written in the manual:
try {
ws.send(data);
}
catch (e) {
// handle error
}

You can use a callback to catch this error:

ws.send(data, function data(err) {
  if (err) handleError(err);
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cmnstmntmn picture cmnstmntmn  路  4Comments

anonaka picture anonaka  路  5Comments

binarykitchen picture binarykitchen  路  5Comments

nabeelio picture nabeelio  路  5Comments

HanHtoonAung picture HanHtoonAung  路  3Comments