diff --git a/nodes/core/io/10-mqtt.html b/nodes/core/io/10-mqtt.html
index 4e4613ba7..70767edb4 100644
--- a/nodes/core/io/10-mqtt.html
+++ b/nodes/core/io/10-mqtt.html
@@ -187,6 +187,10 @@
+
+
+
+
@@ -283,6 +287,7 @@
}
}},
usetls: {value: false},
+ usews: {value: false},
verifyservercert: { value: false},
compatmode: { value: true},
keepalive: {value:60,validate:RED.validators.number()},
@@ -344,6 +349,10 @@
this.usetls = false;
$("#node-config-input-usetls").prop("checked",false);
}
+ if (typeof this.usews === 'undefined') {
+ this.usews = false;
+ $("#node-config-input-usews").prop('checked', false);
+ }
if (typeof this.compatmode === 'undefined') {
this.compatmode = true;
$("#node-config-input-compatmode").prop('checked', true);
diff --git a/nodes/core/io/10-mqtt.js b/nodes/core/io/10-mqtt.js
index b01df652b..80059858e 100644
--- a/nodes/core/io/10-mqtt.js
+++ b/nodes/core/io/10-mqtt.js
@@ -36,6 +36,7 @@ module.exports = function(RED) {
this.port = n.port;
this.clientid = n.clientid;
this.usetls = n.usetls;
+ this.usews = n.usews;
this.verifyservercert = n.verifyservercert;
this.compatmode = n.compatmode;
this.keepalive = n.keepalive;
@@ -69,6 +70,9 @@ module.exports = function(RED) {
if (typeof this.usetls === 'undefined') {
this.usetls = false;
}
+ if (typeof this.usews === 'undefined') {
+ this.usews = false;
+ }
if (typeof this.compatmode === 'undefined') {
this.compatmode = true;
}
@@ -86,10 +90,18 @@ module.exports = function(RED) {
// Create the URL to pass in to the MQTT.js library
if (this.brokerurl === "") {
- if (this.usetls) {
- this.brokerurl="mqtts://";
+ if (this.usews) {
+ if (this.usetls) {
+ this.brokerurl="wss://";
+ } else {
+ this.brokerurl="ws://";
+ }
} else {
- this.brokerurl="mqtt://";
+ if (this.usetls) {
+ this.brokerurl="mqtts://";
+ } else {
+ this.brokerurl="mqtt://";
+ }
}
if (this.broker !== "") {
this.brokerurl = this.brokerurl+this.broker+":"+this.port;
diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json
index 8562b961f..d201174d9 100644
--- a/nodes/core/locales/en-US/messages.json
+++ b/nodes/core/locales/en-US/messages.json
@@ -314,6 +314,7 @@
"keepalive": "Keep alive time (s)",
"cleansession": "Use clean session",
"use-tls": "Enable secure (SSL/TLS) connection",
+ "use-ws": "Enable MQTT over WebSocket connection",
"tls-config":"TLS Configuration",
"verify-server-cert":"Verify server certificate",
"compatmode": "Use legacy MQTT 3.1 support"