java.lang.Exception: No MQTT client - OpenHab 2.5

Hi everyone,

I am running openHAB of a Raspberry Pi3 and am just now starting to get it all setup. My very first task to try and get some sonoff basics working via Tasmota and MQTT. They have all been flashed and are working.

The following was all done via the PaperUI.

I added the MQTT Binding and the MQTT Embedded broker to the system. Went through and set them up and tested them with MQTTfx. Everything works just fine (I was able to connect to the MQTT server and send/receive topics). So I configured my Sonoff for the MQTT server, and I then subscribed to the command and state topics on MQTTFX and when I press the button on the sonoff I can see the topic being sent in MQTTfx and I can also publish a topic from MQTTfx and see the sonoff change states.

Everything seems to be working as expected.

Next step was to add the sonoff as a generic MQTT thing with the embedded MQTT Broker as it’s bridge and this went fine, and the thing showed up as online and happy. Next was to add the channel to the it, which I did, giving it the state and command topics that I verified as working in MQTTfx. As soon as I did this the thing went from online to:

OFFLINE - COMMUNICATION_ERROR java.lang.Exception: No MQTT client

I plowed on and linked a new switch item to it, which shows up in the control section, toggling that does nothing. I have even gone so far as to delete everything and start all over about 2 or 3 times, with no luck.

Spending an hour trying to google this issue did not really yield much of anything, and I have no idea what is going on here. I am running version 2.5 of openHAB which apparently fixed a bug that could cause this, so that’s not it. There were some mentioned of editing a MQTT.cfg file, but that file is missing on my install. Lots of mentions to editing config files manually, but no mention of where these files as (and my /etc/openhab2/things folder is empty).

So what I am doing wrong here? How do I get this working?

Welcome to the community!

I recommend not using the embedded broker as it’s no longer supported. Uninstall it and use mosquitto. If you installed OH via the openhabian image you can install the mosqutto broker with the openhabian-config tool (from command line: sudo openhabian-config).

If you did not install the openhabian image you can add it using:

# install git
sudo apt-get update
sudo apt-get install git

# download and link
sudo git clone https://github.com/openhab/openhabian.git /opt/openhabian
sudo ln -s /opt/openhabian/openhabian-setup.sh /usr/local/bin/openhabian-config

# execute
sudo openhabian-config
2 Likes

For the record. I rebooted the system and it all started working. Probably not a universal fix, so YMMV, but worth a shot if you experience the same thing.

But I decided to remove the system broker and go with Mosquitto as suggested. I uninstalled the system MQTT broker and installed Mosquitto. And that broke everything I had working with MQTT.

How do I tell openhab to use Mosquitto?

I went to Configuration -> Services -> MQTT system broker connection and created a new broker connection. Gave it a name and set the hostname to localhost, set the username to openhabian left the password blank and saved it.

I then uninstalled and re-installed the MQTT binding. But there does not seem to be anything to configure there.

All my MQTT things show as offline, and the only bridge available for the devices is the old one, which I removed.

So yeah, what did I miss here?

Eh, nevermind. I worked it out. I had to remove the system MQTT Broker thing and add a new one for the Mosquitto MQTT Broker. They are all online again and appear to be working.