diff --git a/.changeset/short-pots-listen.md b/.changeset/short-pots-listen.md new file mode 100644 index 0000000..c4aab8c --- /dev/null +++ b/.changeset/short-pots-listen.md @@ -0,0 +1,5 @@ +--- +"vue-paho-mqtt": patch +--- + +No WSS attempt when `useSSL` is `false`. diff --git a/src/pahoMqttPlugin/utils/connectClient.ts b/src/pahoMqttPlugin/utils/connectClient.ts index eddd1ba..cc1481c 100644 --- a/src/pahoMqttPlugin/utils/connectClient.ts +++ b/src/pahoMqttPlugin/utils/connectClient.ts @@ -72,10 +72,15 @@ export const connectClient = ({ (MqttOptions.keepAliveInterval || defaultMqttOptions.keepAliveInterval!) / 1000, cleanSession: MqttOptions.cleanSession, - uris: [ - `wss://${MqttOptions.host}:${MqttOptions.port}${MqttOptions.path}`, - `ws://${MqttOptions.host}:${MqttOptions.port}${MqttOptions.path}`, - ], + uris: + MqttOptions.useSSL === false + ? [ + `ws://${MqttOptions.host}:${MqttOptions.port}${MqttOptions.path}`, + ] + : [ + `wss://${MqttOptions.host}:${MqttOptions.port}${MqttOptions.path}`, + `ws://${MqttOptions.host}:${MqttOptions.port}${MqttOptions.path}`, + ], onSuccess: () => { resolve(true); onConnectCallback();