mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
e6369820a9
commit
45913e5ee8
@ -184,6 +184,8 @@ module.exports = function(RED) {
|
|||||||
this.connect = function () {
|
this.connect = function () {
|
||||||
if (!node.connected && !node.connecting) {
|
if (!node.connected && !node.connecting) {
|
||||||
node.connecting = true;
|
node.connecting = true;
|
||||||
|
console.log("going for connect");
|
||||||
|
try {
|
||||||
node.client = mqtt.connect(node.brokerurl ,node.options);
|
node.client = mqtt.connect(node.brokerurl ,node.options);
|
||||||
node.client.setMaxListeners(0);
|
node.client.setMaxListeners(0);
|
||||||
// Register successful connect or reconnect handler
|
// Register successful connect or reconnect handler
|
||||||
@ -243,12 +245,11 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Register connect error handler
|
// Register connect error handler
|
||||||
node.client.on('error', function (error) {
|
// The client's own reconnect logic will take care of errors
|
||||||
if (node.connecting) {
|
node.client.on('error', function (error) {});
|
||||||
node.client.end();
|
}catch(err) {
|
||||||
node.connecting = false;
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user