diff --git a/nodes/core/io/10-mqtt.js b/nodes/core/io/10-mqtt.js index c4e9f57d3..a01952940 100644 --- a/nodes/core/io/10-mqtt.js +++ b/nodes/core/io/10-mqtt.js @@ -116,7 +116,6 @@ module.exports = function(RED) { this.broker = n.broker; this.brokerConfig = RED.nodes.getNode(this.broker); - var node = this; if (this.brokerConfig) { this.status({fill:"red",shape:"ring",text:"disconnected"},true); @@ -129,6 +128,7 @@ module.exports = function(RED) { this.client.publish(msg); } }); + var node = this; this.client.on("connectionlost",function() { node.status({fill:"red",shape:"ring",text:"disconnected"}); });