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

Sockets crashes with incomprehensible error message #1916

Closed
jestorocompany opened this issue Jul 14, 2021 · 2 comments
Closed

Sockets crashes with incomprehensible error message #1916

jestorocompany opened this issue Jul 14, 2021 · 2 comments

Comments

@jestorocompany
Copy link

Hi,

we implemented a chat based on ws. I worked for quite a while without problems - but recently the socket seems to crash every 20 minutes or so with the error message:

RangeError: Invalid WebSocket frame: invalid status code 22373

We have no clue what exactly this message means and what to do about it.

Maybe, someone has a hint for us.

Thanks in advance
Michael

@lpinca
Copy link
Member

lpinca commented Jul 14, 2021

It means a peer is receiving a close frame with an invalid status code:

const WebSocket = require('ws');

const wss = new WebSocket.Server({ port: 0 }, function () {
  const ws = new WebSocket(`ws://localhost:${wss.address().port}`);

  ws.on('open', function () {
    ws._socket.write(Buffer.from('8882000000005765', 'hex'));
  });
});

wss.on('connection', function (ws) {
  ws.on('error', console.error);
});

Add a listener for the 'error' event.

@lpinca
Copy link
Member

lpinca commented Jul 15, 2021

I'm closing this as answered. Discussion can continue if needed.

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

No branches or pull requests

2 participants