Occasional players connecting 10 seconds
version:3.0.0
Node.js version(s):v6.10.0
OS version(s):windows server 2008 r2 enterprise
no way
NO ERROR
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)
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);
});
Most helpful comment
@n-elloco assuming that permessage-deflate is disabled on the server (it is by default) you can send the following bytes.