coldfire84 / node-red-alexa-home-skill-v3-web

Web Service/ API for Alexa and Google Home Node-RED Smart Home Control
https://red.cb-net.co.uk/
Apache License 2.0
52 stars 8 forks source link

Multiple Node-RED Instances, MQTT Connection #64

Closed hobbyquaker closed 5 years ago

hobbyquaker commented 5 years ago

When using multiple instances of Node-RED with node-red-alexa-home-skill-v3-web the connection to the MQTT broker is only possible from one instance at a time. As soon as the second connects the first one is disconnected, then the first one reconnects and the second is disconnected and so on. Is it possible to change that behavior? I don't now if it just depends on the MQTT username or the client-id or if it depends on the broker config?

roberttco commented 5 years ago

This seems like the same client ID is being used for each connection.

coldfire84 commented 5 years ago

This seems like the same client ID is being used for each connection.

Yes, as you say in the node-red-contrib the MQTT clientId is defined as:

clientId: node.username,

Configuring multiple config nodes (either on the same, or different Node-RED instances) will cause continuous reconnects across the config nodes.

coldfire84 commented 5 years ago

@hobbyquaker what's your use case for enabling multiple Node-RED instances to connect?

hobbyquaker commented 5 years ago

On each Hardware Interface I'm using I run a single Node-RED instance. E.g. there is a Pi that has a CC2531 USB Stick and connects all Zigbee Devices. Another Pi has an RPI-RF-MOD Header that communicates with Homematic-IP Devices. A third Pi has an Infrared Transceiver and controls some TV/Hifi stuff. All of them have their own Node-RED instance. They can communicate over MQTT - but to minimize SPOFs and let them be able to work standalone without Alexa outages it would be convenient for me to be able to connect to your service from all of them.

coldfire84 commented 5 years ago

I've published Node-RED contrib 0.4.50 which generates a unique MQTT clientId. You can update your instance(s) and confirm functionality.

https://github.com/coldfire84/node-red-contrib-alexa-home-skill-v3/commit/f43bbd82a67da07aaa8e0c0c9f20c028c40554ce

coldfire84 commented 5 years ago

Please re-open if testing new nodes show issue.