MQTT node should only send message if topic actually specified (string)

This commit is contained in:
Dave C-J 2014-09-08 20:01:28 +01:00
parent 1a5a548fbf
commit ab4d3c025e
1 changed files with 4 additions and 1 deletions

View File

@ -95,7 +95,10 @@ module.exports = function(RED) {
if (node.topic) {
msg.topic = node.topic;
}
this.client.publish(msg);
if (typeof msg.topic === "string") { // topic must be a string
this.client.publish(msg); // send the message
}
else { node.warn("Invalid topic specified"); }
}
});
this.client.on("connectionlost",function() {