Search code examples
mqttnode-red

Is it possible to keep a connection with two different MQTT Brokers when using the Node-RED?


I have a server on the cloud that receives MQTT messages and I'm running the Node-RED on a Raspberry pi on my localhost...

With the Raspberry, I'm receiving data from different devices using the MQTT protocol. And until here, it works great! The problem is when I try to receive messages from the MQTT broker that's running locally (on the Raspberry) and then send these messages to other MQTT broker that's running on another server. Something like this image:

Example

When I try to use two different brokers with the Node-RED, it automatically updates all other nodes to the last broker that I had configured. So, is it possible to open a connection with two different MQTT Brokers when I'm using the Node-RED?


Solution

  • In the MQTT node edit dialog, the 'Server' field is a select box. It lists all of the broker configurations you have in your flow.

    To add a connection to a different broker, select the 'Add new mqtt-broker...' option then click the button next to the select box.

    That adds a new connection configuration rather than edit the one already being used by your existing nodes.