Websocket RangeError: Invalid WebSocket frame: RSV2 and RSV3 must be clear

See original GitHub issue
  • [ x] I’ve searched for any related issues and avoided creating a duplicate issue.

Description

I’m using ws as a client in my node application, and when I attempt to connect to the host, the connection is closed with the error ‘Websocket RangeError: Invalid WebSocket frame: RSV2 and RSV3 must be clear’.

It is worth noting that the connection is successful to a different host, but I believe this is a client issue?

It’s also worth noting that faye-websocket functions correctly in the same situation.

Reproducible in:

version: 5.1.1 Node.js version(s): 8.9.4 OS version(s): Windows 7 Professional v6.1 (build 7601)

Steps to reproduce:

  1. Run the following code inside of a Node Application:
const WebSocket = require('ws')

const ws = new WebSocket('ws://site:8765/ws')

ws.on('message', data => {
  console.log(data)
})
ws.on('error', err => { console.log(err) })
ws.on('close', () => { console.log('close') })

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:27 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
tgraupmanncommented, Feb 7, 2021

'error' events must be handled.

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

That’s all it was. The server just needed an error handler to avoid crashing. And now it logs errors without exiting. Thanks!

3reactions
lpincacommented, Feb 7, 2021

'error' events must be handled.

wss.on('connection', function(ws) {
  ws.on('error', console.error);
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error `RSV2 and RSV3 must be clear` in `ws` - Stack Overflow
My app uses ws in Express server to serve WebSocket. I have seen a lot of errors in production ...
Read more >
RSV2 and RSV3 must be clear" error and websocket ...
When I try to place an order using the JavaScript client, I get the above error mentioned in the title. Then the websocket...
Read more >
Uncaught Exception in engine.io - Vulners
RangeError : Invalid WebSocket frame: RSV2 and RSV3 must be clear at Receiver.getInfo (/.../node_modules/ws/lib/receiver.js:176:14) at ...
Read more >
Uncaught Exception in engine.io | CVE-2022-21676 | Snyk
node:events:368 throw er; // Unhandled 'error' event ^. RangeError: Invalid WebSocket frame: RSV2 and RSV3 must be clear at Receiver.
Read more >
Invalid WebSocket frame: RSV2 and RSV3 must be clear
Websocket RangeError: Invalid WebSocket frame : RSV2 and RSV3 must be clear. ws. 06 April 2018 Posted by ztnark. [ x] I've searched...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found