-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
handleProtocols property is not executed if no protocols are present #1552
Comments
This is by design. There is no subprotocol to negotiate. |
Thanks for your answer. I think I got it. I managed to achieve what I need using const verifyClient: VerifyClientCallbackAsync = (info, cb) => {
const protocol = info.req.headers['sec-websocket-protocol'];
if (protocol && protocol.includes(PROTOCOL)) {
cb(true);
} else {
cb(false, 403);
}
}; I suppose the same could be achieved replacing Thank you so much and sorry for the noise. |
Yes, that works too. See also #377 (comment). |
issue.
Description
I'm using the
handleProtocols
property when creating a server to force clients connecting to the server to send the name of the required protocol. But when the client doesn't send any protocol, the function is not executed so validation can't be done.Reproducible in:
Steps to reproduce:
Create a
WebSocket.Server
with a function in thehandleProtocols
property of the Options objectCreate a client connecting with the server that doesn't send the
Sec-WebSocket-Protocol
.The connection is established without calling the handleProtocols function.
Expected result:
I expect it to be executed always to be able to reject the request if the required protocol is not sent by the client.
Actual result:
Function is not executed and the socket is established.
Attachments:
The text was updated successfully, but these errors were encountered: