Unable to connect to Mosquitto broker

Hi All,

I currently have a Mosquitto broker instance up and running. It is running on the same server as Home Assistant however I am attempting to connect to the broker via public fqdn/Cloudflare (connecting to localhost doesn’t work either).

The traffic flow is as follows:
Home Assistant -> mqtt.domain.com:443 -> Cloudflare -> haproxy -> Mosquitto Broker

I am able to connect to the broker from my Android phone using OwnTracks (including at home on the same network as the Home Assistant service). I am also able to connect from http://www.hivemq.com/demos/websocket-client/

Home Assistant fails to connect but in the logs reports “[homeassistant.components.mqtt] Successfully reconnected to the MQTT server” every 2 minutes.

Thanks!

try changing your client ID in your home assistant config. You cannot have more than one client with the same ID hit the broker. bad things happen.

Thanks for the response. I have tried different client IDs but it doesn’t seem to make a difference. Mosquitto never even seems to see a connection coming from the HA server even though the HA server claims to have connected.

I have also checked that mosquitto is definitely running on port 1883 because I had originally tried to use the built-in hbmqtt service.

Nevermind. Figured it out. Home Assistant doesn’t seem to work with mqtt over websockets.

Quick followup on this since I have managed to get mqtt to work using websockets. The only difference is setting the mqtt host in the .yaml to ws://mqtt.domain.com/ws and port to 443. This doesn’t work through the web UI integrations config of MQTT though.

1 Like