Skip to content

calling verifyClient callback multiple times results in "RSV1 must be clear" errors #1272

Closed
@delasky

Description

@delasky
  • [ X] I've searched for any related issues and avoided creating a duplicate issue.

Description

Calling the verifyClient callback twice in verifyClient function triggers an "Invalid WebSocket frame: RSV1 must be clear"

It's not clear to me why this leads to that specific error. Calling the callback multiple times should probably be expressly forbidden with a related error message.

The error occurs when this.completeUpgrade is called twice.

I also think this might be the root cause behind #1238.

Reproducible in:

version:
Node.js version(s): 7.4.0
OS version(s): Mac OS X 10.10.5

Steps to reproduce:

  1. run the following code
let WebSocket = require('ws')

let verify = (info, cb) => {
    cb(true)
    cb(true)
}

const wss = new WebSocket.Server({ port: 8080, verifyClient: verify});

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
      console.log('received: %s', message);
    });

  ws.send('something');
});

const ws = new WebSocket('ws://localhost:8080');

ws.on('open', function open() {

  ws.send("hello");
})

Expected result:

A different error message, or ignore subsequent calls of the verifyClient callback.

Actual result:

RSV1 must be clear

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions