diff --git a/packages/node_modules/@node-red/nodes/core/io/10-mqtt.js b/packages/node_modules/@node-red/nodes/core/io/10-mqtt.js index f6702e902..379cf8a96 100644 --- a/packages/node_modules/@node-red/nodes/core/io/10-mqtt.js +++ b/packages/node_modules/@node-red/nodes/core/io/10-mqtt.js @@ -334,7 +334,7 @@ module.exports = function(RED) { } }; - this.publish = function (msg) { + this.publish = function (msg,done) { if (node.connected) { if (msg.payload === null || msg.payload === undefined) { msg.payload = ""; @@ -350,7 +350,10 @@ module.exports = function(RED) { qos: msg.qos || 0, retain: msg.retain || false }; - node.client.publish(msg.topic, msg.payload, options, function(err) {return}); + node.client.publish(msg.topic, msg.payload, options, function(err) { + done && done(); + return + }); } }; @@ -453,7 +456,7 @@ module.exports = function(RED) { if (this.brokerConn) { this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"}); - this.on("input",function(msg) { + this.on("input",function(msg,send,done) { if (msg.qos) { msg.qos = parseInt(msg.qos); if ((msg.qos !== 0) && (msg.qos !== 1) && (msg.qos !== 2)) { @@ -468,9 +471,13 @@ module.exports = function(RED) { } if ( msg.hasOwnProperty("payload")) { if (msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) { // topic must exist - this.brokerConn.publish(msg); // send the message + this.brokerConn.publish(msg, done); // send the message + } else { + node.warn(RED._("mqtt.errors.invalid-topic")); + done(); } - else { node.warn(RED._("mqtt.errors.invalid-topic")); } + } else { + done(); } }); if (this.brokerConn.connected) { diff --git a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js index ec5290835..d290ae244 100644 --- a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js @@ -50,7 +50,7 @@ module.exports = function(RED) { noprox = proxyConfig.noproxy; } - this.on("input",function(msg) { + this.on("input",function(msg,nodeSend,nodeDone) { var preRequestTimestamp = process.hrtime(); node.status({fill:"blue",shape:"dot",text:"httpin.status.requesting"}); var url = nodeUrl || msg.url; @@ -62,12 +62,14 @@ module.exports = function(RED) { } if (!url) { node.error(RED._("httpin.errors.no-url"),msg); + nodeDone(); return; } // url must start http:// or https:// so assume http:// if not set if (url.indexOf("://") !== -1 && url.indexOf("http") !== 0) { node.warn(RED._("httpin.errors.invalid-transport")); node.status({fill:"red",shape:"ring",text:"httpin.errors.invalid-transport"}); + nodeDone(); return; } if (!((url.indexOf("http://") === 0) || (url.indexOf("https://") === 0))) { @@ -261,10 +263,12 @@ module.exports = function(RED) { } } catch(err) { node.error(RED._("httpin.errors.invalid-payload"),msg); + nodeDone(); return; } } else { node.error(RED._("httpin.errors.invalid-payload"),msg); + nodeDone(); return; } } @@ -320,7 +324,8 @@ module.exports = function(RED) { } msg.payload = err.toString() + " : " + url; msg.statusCode = err.code; - node.send(msg); + nodeSend(msg); + nodeDone(); }else{ msg.statusCode = res.statusCode; msg.headers = res.headers; @@ -354,7 +359,8 @@ module.exports = function(RED) { } } node.status({}); - node.send(msg); + nodeSend(msg); + nodeDone(); } }); }); diff --git a/packages/node_modules/@node-red/nodes/core/io/22-websocket.js b/packages/node_modules/@node-red/nodes/core/io/22-websocket.js index 5240b544a..957b7d8ed 100644 --- a/packages/node_modules/@node-red/nodes/core/io/22-websocket.js +++ b/packages/node_modules/@node-red/nodes/core/io/22-websocket.js @@ -309,7 +309,7 @@ module.exports = function(RED) { node.status(status); }); } - this.on("input", function(msg) { + this.on("input", function(msg, nodeSend, nodeDone) { var payload; if (this.serverConfig.wholemsg) { var sess; @@ -337,6 +337,7 @@ module.exports = function(RED) { }); } } + nodeDone(); }); this.on('close', function() { node.status({});