Closed wyzxxx123 closed 7 years ago
This error means that the client is sending a compressed frame but the permessage-deflate extension is disabled.
There isn't anything actionable to do apart from handling the error.
thx
hey @lpinca got same error when using ws
. interesting that when I use uws
this error doesn't happens on server side. looks like there is way to avoid this error.. any idea?
uws
has no errors, it simply closes the connection when an error occurs without any notice. Add a listener for the 'error'
event to prevent the process from crashing and eventually ignore errors. Also see https://github.com/websockets/ws/issues/1354#issuecomment-379372114 which might be related.
Hello. I'm getting the same error if the client connecting is from MacOS/Chrome, but NOT from Windows/Chrome. What can I do on the Server or Client to be able to connect from MacOS? I can't make it work on the Mac. Same code everywhere.... :-(
I am experiencing the same issue on node v8.11.3 and v10.6.0
node_modules/ws/lib/receiver.js:167
return error(RangeError, 'RSV1 must be clear', true, 1002);
^
RangeError: Invalid WebSocket frame: RSV1 must be clear
at Receiver.getInfo (/node_modules/ws/lib/receiver.js:167:14)
at Receiver.startLoop (/node_modules/ws/lib/receiver.js:121:22)
at Receiver._write (/node_modules/ws/lib/receiver.js:69:10)
at doWrite (_stream_writable.js:397:12)
at writeOrBuffer (_stream_writable.js:383:5)
at Receiver.Writable.write (_stream_writable.js:290:11)
at TLSSocket.socketOnData (/node_modules/ws/lib/websocket.js:795:35)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
at TLSWrap.onread (net.js:597:20)
Have wrapped ws.send() in a try / catch as well as set perMessageDeflate=false
in the client constructor options.
This error means that the client is sending a compressed frame but the permessage-deflate extension is disabled.
There isn't anything actionable to do apart from handling the error.
And how would we handle this particular error?
I've read this https://github.com/websockets/ws/issues/1191#issuecomment-324076671.
But I already got the following code running in my server and it doesn't seem to be catching this error:
webSocket.on('error', function(error) {
console.log(webSocket.id + ':' + error)
})
@goktugyil wow we were both working on this problem at the same time today. See my comment here: https://github.com/nodejs/node/pull/17806#issuecomment-446213378. It appears that Node v10.14.0 introduced some kind of regression.
I'm using v10.11.0 in dev environment and v10.10.0 in the server that crashed. Server crashed like 60 times in 2 minutes. And then nothing happened for a day. What do you suggest I do about this?
@goktugyil no clue. on our end, we were able to isolate it to v10.14.x
@shellscape I see. :( Is there a specific place of origin for this bug? I'm not using permessage-deflate.
@goktugyil here is a quick way to reproduce:
const { request } = require('http');
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 0 }, () => {
const req = request({
port: wss.address().port,
headers: {
Connection: 'Upgrade',
Upgrade: 'websocket',
'Sec-WebSocket-Key': 'dGhlIHNhbXBsZSBub25jZQ==',
'Sec-WebSocket-Version': 13
}
});
req.end(Buffer.from([0xC1, 0x05, 0x5f, 0xeb, 0xe5, 0xf0, 0x1c]));
});
wss.on('connection', (ws) => {
ws.on('error', console.error);
});
port: wss.address().port,
How does this work without init() first?
@lpinca would that be a simpler reproduction that should be posted on https://github.com/nodejs/node/issues/24958?
@shellscape no because what I posted above is done on purpose, the same error was caused by a bug in Node.js core but that is different. The first byte was dropped so the frame was still malformed but not on purpose. Hope it makes sense.
@goktugyil here is a quick way to reproduce:
const { request } = require('http'); const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 0 }, () => { const req = request({ port: wss.address().port, headers: { Connection: 'Upgrade', Upgrade: 'websocket', 'Sec-WebSocket-Key': 'dGhlIHNhbXBsZSBub25jZQ==', 'Sec-WebSocket-Version': 13 } }); req.end(Buffer.from([0xC1, 0x05, 0x5f, 0xeb, 0xe5, 0xf0, 0x1c])); }); wss.on('connection', (ws) => { ws.on('error', console.error); });
I couldn't get this to compile at all.
I am still having this issue in production, can @wyzxxx123 or somebody else reopen it?
I found I get this serverside when using an espruino esp32 and trying to send a json object directly. The fix is to first turn it into a string ws.send(JSON.stringify({data:"asdf}));
Hello, @lpinca. We use your library. Generally, everything is OK, but sometimes there are some clients when we got the error RSV1 must be clear
. I read different threads here, but I don't understand, how I can reproduce it on the client side. What should I send to server for getting this error?
@n-elloco assuming that permessage-deflate is disabled on the server (it is by default) you can send the following bytes.
0xc1 0x80
const WebSocket = require('ws');
const server = new WebSocket.Server({ port: 0 }, function () {
const ws = new WebSocket(`ws://localhost:${server.address().port}`);
ws.on('open', function () {
ws._socket.write(Buffer.from([0xc1, 0x80]));
});
});
server.on('connection', function (ws) {
ws.on('error', console.error);
});
The code above produces the following error:
I've ran it 20 times, couldn't get it to crash anything.
I've also ran this one, errors, but no crashes. https://github.com/websockets/ws/issues/1140#issuecomment-446225316
https://sentry.io/share/issue/5193b3cca33545d8971852049a5e2457/
However when this issue happens to me, 83% of the time it is handled. 17% of the time it is a full server crash. Does the exception stack make any sense to anyone?
The socket that connected is using Chrome 99.0.4844.51 Windows 10.0. For my side looks like a normal user
It seems when this event happens, it happens multiple times around the same times, makes sense.
I get billions of socket connections and events on my site, no problem. But randomly I get a full server crash from RSV1 once every few months, I still have no idea what causes it.
Currently using Node: v12.22.10 ws: 6.2.2
i don't even have a line of my code where i can put a try {} catch statement :(
ip[x-forwarded-for]: 186.210.46.219
node:events:491
throw er; // Unhandled 'error' event
^
RangeError: Invalid WebSocket frame: RSV1 must be clear
at Receiver.getInfo (/data/nostr/server/node_modules/ws/lib/receiver.js:199:14)
at Receiver.startLoop (/data/nostr/server/node_modules/ws/lib/receiver.js:146:22)
at Receiver._write (/data/nostr/server/node_modules/ws/lib/receiver.js:84:10)
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at Socket.socketOnData (/data/nostr/server/node_modules/ws/lib/websocket.js:1274:35)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
Emitted 'error' event on WebSocket instance at:
at Receiver.receiverOnError (/data/nostr/server/node_modules/ws/lib/websocket.js:1160:13)
at Receiver.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'WS_ERR_UNEXPECTED_RSV_1',
[Symbol(status-code)]: 1002
}
Description
Occasional players connecting 10 seconds
Reproducible in:
version:3.0.0 Node.js version(s):v6.10.0 OS version(s):windows server 2008 r2 enterprise
Steps to reproduce:
no way
Expected result:
NO ERROR
Actual result:
Error: RSV1 must be clear at Receiver.getInfo (D:\HallServer\node_modules\ws\lib\Receiver.js:191:18) at Receiver.startLoop (D:\HallServer\node_modules\ws\lib\Receiver.js:153:16) at Receiver.add (D:\HallServer\node_modules\ws\lib\Receiver.js:139:10) at Socket._ultron.on (D:\HallServer\node_modules\ws\lib\WebSocket.js:142:22) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:548:20)
Attachments: