Mqtt setup struggles

Raspi 2 B with latest OH and MQTT server installed through openhabian-config (this is an old pi I had lying around, there is currently no stock of any pi 3 or 4’s at any retailer I’ve checked so it’s a temp solution)

I’ve tried all sorts of combinations of localhost, localhost:1883, the pi’s IP address with no luck, I’m getting a configuration error in the MQTT thing and the following error:

2020-07-02 22:56:57.355 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘localhost’ with clientid 48c3ff57-cf90-4e41-9341-57fe6896a2c7

2020-07-02 22:57:57.364 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘localhost’. Next attempt in 60000ms

I have MQTT lens installed and after installing the broker I could see a tasmota saying something about the current time when I had subscribed to # on the pi’s IP address but that went offline, I still have an active connection and subscription to localhost though there’s no activity on #

The docs and tutorials I found all seem to be point towards MQQT v1 because their menus and settings differ from what I have available.

Totally confused about what to change and where, do I change to my own ID? is this the broker ID it keeps looking for? What is client Id mentioned above from the log? Where do i set that?

Deeply frustrated and will appreciate any help

What is the MQTT broker that has been installed? Is it Mosquitto, or openHAB’s Moquette?

How are you configuring things? Via PaperUI or configuration files?

And what MQTT devices have you got setup? Did you have this working previously?

And ultimately, what are you trying to achieve? Control a single Tasmota-flashed device via MQTT through openHAB?

1 Like

HI, Thank you for replying,

What is the MQTT broker that has been installed? Is it Mosquitto, or openHAB’s Moquette?
Mosquitto I believe, installed through optional software menu in openhabian-config

How are you configuring things? Via PaperUI or configuration files?
I’ve tried both, first through config files as per documentation then after I found the options in Paper UI

And what MQTT devices have you got setup? Did you have this working previously?
I have 1x Tasmota flashed Sonoff as a test, once the system is working i’ll flash another 20 or so sonoffs to tasmota.

And ultimately, what are you trying to achieve? Control a single Tasmota-flashed device via MQTT through openHAB?
I’m attempting to move from eWeLink to openhab to control lighting in the house, I have moved a trial installation of openhab from my pc to a raspi 2B while I wait for a Pi 4B to become available, moving forward I wanted to get the lighting working.

I’ve noticed now that it seems that mosquitto is not running on the pi, it doesn’t give a reason, I noticed the error when i tried to reinstall the broker o the pi and add a password to try get a connection. I’l post the error code now

[23:58:10] openhabian@openhab:~$ sudo systemctl status mosquitto
[sudo] password for openhabian:
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset
Active: failed (Result: exit-code) since Thu 2020-07-02 23:49:32 SAST; 9min a
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 3623 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (
Main PID: 3623 (code=exited, status=1/FAILURE)

Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Service RestartSec=100ms
Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Scheduled restart job, re
Jul 02 23:49:32 openhab systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.
Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Start request repeated to
Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Failed with result 'exit-
Jul 02 23:49:32 openhab systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 B
lines 1-14/14 (END)…skipping…
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-07-02 23:49:32 SAST; 9min ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 3623 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 3623 (code=exited, status=1/FAILURE)

Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.
Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Jul 02 23:49:32 openhab systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.
Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Start request repeated too quickly.
Jul 02 23:49:32 openhab systemd[1]: mosquitto.service: Failed with result ‘exit-code’.
Jul 02 23:49:32 openhab systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.

Looks like you’ve isolated the main issue - have you tried restarting the pi itself? Mosquitto is a 3rd party program, so you’re best off Googling for the errors! One thing you could check is to make sure nothing else on your pi is trying to access the same port: that will make Mosquitto cry.

Once you get Mosquitto up and running, do double check your openHAB stuff to make sure that you haven’t defined stuff twice: once in paperUI, once in configuration files - that never ends well!

Did the installation on your PC work fine with MQTT?

EDIT: if you haven’t got this setup on your PC, I’d try getting it all working on there first - just a bit easier than (presumably) SSHing into the pi. If you configure using files, you then only need to copy them over to the pi, and ensure you have the correct bindings and transforms installed.

1 Like

I never got to installing Mqtt on my pc, so I’m not sure.

I think you’ve raised some good points about configuring in 2 places and the port usage though.

I’ll have a look with a fresh mind this afternoon and possibly refresh everything, otherwise I think I must stick to my original plan and use an old laptop.

Seems to have been resolved…somehow.

I deleted the config files and all settings in PaperUI, added them again fresh and only set location as localhost (not localhost:1883, that gave an error)

openhabian as username - no password. Unfortunately still cannot install new mosquitto through openhabian-config though.

Went into puTTY and typed sudo mosquitto and boom there’s a connection in the logs and a connection from 127.0.0.1 under the sudo mosquitto command I typed in.

Thank you very much for the help!