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 () {
|
||||
if (!node.connected && !node.connecting) {
|
||||
node.connecting = true;
|
||||
console.log("going for connect");
|
||||
try {
|
||||
node.client = mqtt.connect(node.brokerurl ,node.options);
|
||||
node.client.setMaxListeners(0);
|
||||
// Register successful connect or reconnect handler
|
||||
@ -243,12 +245,11 @@ module.exports = function(RED) {
|
||||
});
|
||||
|
||||
// Register connect error handler
|
||||
node.client.on('error', function (error) {
|
||||
if (node.connecting) {
|
||||
node.client.end();
|
||||
node.connecting = false;
|
||||
// The client's own reconnect logic will take care of errors
|
||||
node.client.on('error', function (error) {});
|
||||
}catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user