MQTT binding not connecting to mosquitto

Hello all,

I have an issue starting the MQTT binding within openhab2.
Openhabian is running an old RPI2 and seems to be running as it should.
I can connect with the app and the basic ui is looking OK.

I set up the mosquitto broker and installer the MQTT binding.
An app on my android phine can read the data from the RPI (on port 1883) send by an ESP8266.
But openHAB isn’t connecting.

in MQTT.cfg the following lines are used:
mymosquitto.url=tcp://192.168.0.129:1883
mymosquitto.clientId=openhab2

When I check the openhab.log or events.log I don’t see any connection attempts.
Also mosquitto.log doesn’t show any connection attempts from the RPI.

Restarted the PI and reinstalled the MQTT binding, mosquitto multiple times, but no luck.

Any ideas?

Regards and thanks,

Andy

Is the MQTT Broker on the same host (the rPi2) ?
If yes, use: mymosquitto.url=tcp://localhost:1883

Do the following:

  1. Enable debug in the openHAB console: log:set DEBUG org.openhab.binding.mqtt & log:set DEBUG org.openhab.io.transport.mqtt
  2. Uninstall from PaperUI the MQTT Action add-on (if installed)
  3. Shut down OH2
  4. Delete file /var/lib/openhab2/config/org/openhab/mqtt.config and
  5. Start OH2

Also, make sure that the clientId (openhab2) is not used by any other client

Which release of OH2 are you using?

3 Likes

My mqtt.cfg is as follows and it is working. mosquitto broker is mosquitto again in my setup. I also created a user and pass under mosquitto. Maybe your setup doesnot allow unauthenticated?? And maybe you should put “mqtt:” in front of every line.

mqtt:mosquitto.url=tcp://localhost:1883
mqtt:mosquitto.clientId=openhab
mqtt:mosquitto.retain=true
mqtt:mosquitto.async=false
mqtt:mosquitto.user=user
mqtt:mosquitto.pwd=pass

Good point!

No, it should be without mqtt: in openHAB2 since we are using a dedicated config file (/etc/openhab2/services/mqtt.cfg) for the MQTT parameters.

Wow, i am on OH2 snapshot #920, and my setup is like this and funny thing it is working? I should check it again. I only use mqttitude maybe that’s why…

Hey guys,

Thanks for your replies…

Unfortunatly your solutions didn’t work.
In the end I re-installed openhabian and gues what… everything works now.
So maybe something went wrong during the first installation??

I had a similar problem due to an initial typo. Cleaning the MQTT settings in the OpenHAB database fixed it for me:

I think this is also what happend when you reinstalled it.

Just to add to this. I had the same problem, I spent hours and hours and hours trying to get it to work. (Literally about 10 hours :frowning: )

Then I uninstalled OpenHAB, reinstalled it… added the MQTT binding and put my IP, user, password in mqtt.confg

And it worked first time!!!

So if you are reading this thread, uninstall/reinstall OpenHAB.

I had a similar issue when I upgraded MQTT to ver 3.1 and it just stopped working for no reason. After uninstalling MQTT action in the PaperUI. everything seems to working fine!! :slight_smile:
Thanks for your suggestion!!

1 Like