[MQTT] Why it is not possible to connect to two brokers

Hey,

when I have two brokers in my network, I can’t connect HA to both of them. I have to configure one as a bridge. But why it is so? As I know, it is possible with ioBroker. I’m just interested in this fact and would be happy if someone could explain it to me.

so long…

Because that is how MQTT works. One broker, multiple clients. Or bridge multiple brokers.

ioBroker is an automation platform not an mqtt broker.

1 Like

I cannot provide you with too many insights, but in software this typically is due to shared state and in this case, automatic naming conventions could play a role too.

TL;DR: Because it was built that way.

I’m not aware of any technical reasons why it shouldn’t be possible. You’d need a client per broker, but I know you cannot set up multiple instances of the MQTT integration, for example, to achieve that.

What I did want to add, is that if you have this need, you need to bridge the other brokers with your main broker. I personally have a setup like this and it works just fine (it’s a feature).

MQTT was designed by Andy Stanford-Clark and others as a low-bandwidth telemetry system for applications like oil and gas fields - lots of remote sensors, and one centralised control centre.

Hub/spoke, main/helper, controller/peripheral, not multi-brain.

Unless you’re running an entire city, there’s no real downside to linking multiple systems to one broker - my home parallel-ran HASS and openHAB with one Mosquitto MQTT broker for a long time. The sensors just publish their unique state topics to one broker, and clients only subscribe to things they want.

For MQTT, I’ve seen HASS automations publishing selected state changes to MQTT (and used them myself to exchange data from HASS to loggers, email, etc), but not seen a wholesale “MQTT router / repeater” as there’s no real need at typical home message volumes.

There are ways to link HASS multiple instances:

James
If this helps, :heart: this post!

Use mqtt bridge

There is a feature request you can vote on

There is in that topic also the reason I am against it.

1 Like