diff --git a/src/lib/connect/index.ts b/src/lib/connect/index.ts index 41dc94e22..e2c62e25a 100644 --- a/src/lib/connect/index.ts +++ b/src/lib/connect/index.ts @@ -106,7 +106,10 @@ function connect( if (opts.unixSocket) { opts.protocol = opts.protocol.replace('+unix', '') as MqttProtocol - } else if (!opts.protocol?.startsWith('ws')) { + } else if ( + !opts.protocol?.startsWith('ws') && + !opts.protocol?.startsWith('wx') + ) { // consider path only with ws protocol or unix socket // url.parse could return path (for example when url ends with a `/`) // that could break the connection. See https://github.com/mqttjs/MQTT.js/pull/1874