fix: ensure protocolVersion is a number in WebSocket options (#6013)

This commit is contained in:
Siddharth Gelera (reaper)
2025-11-06 19:05:35 +05:30
committed by GitHub
parent 1ac128e35c
commit 24a36bc355
2 changed files with 6 additions and 1 deletions

View File

@@ -67,7 +67,11 @@ class WsClient {
};
if (protocolVersion) {
wsOptions.protocolVersion = protocolVersion;
// Force convert to number since `ws` doesn't do it for you
const asNumber = Number(protocolVersion);
if (!isNaN(asNumber)) {
wsOptions.protocolVersion = asNumber;
}
}
const wsConnection = new ws.WebSocket(parsedUrl.fullUrl, protocols, wsOptions);

View File

@@ -13,6 +13,7 @@ ws {
headers {
Sec-WebSocket-Protocol: soap
Sec-WebSocket-Protocol: mqtt
Sec-WebSocket-Version: 13
}
body:ws {