1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Only unsub mqtt node that is being removed

This commit is contained in:
Nick O'Leary 2018-11-08 17:03:41 +01:00
parent 6a6d13b075
commit 073f38c68c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -421,9 +421,12 @@ module.exports = function(RED) {
else { else {
this.error(RED._("mqtt.errors.not-defined")); this.error(RED._("mqtt.errors.not-defined"));
} }
this.on('close', function(done) { this.on('close', function(removed, done) {
if (node.brokerConn) { if (node.brokerConn) {
if (removed) {
// This node has been removed so remove any subscriptions
node.brokerConn.unsubscribe(node.topic,node.id); node.brokerConn.unsubscribe(node.topic,node.id);
}
node.brokerConn.deregister(node,done); node.brokerConn.deregister(node,done);
} }
}); });