openHABian - Mosquitto MQTT failed to start

Try

mkdir -p /var/log/mosquitto /opt/zram/log.bind/mosquitto
chown mosquitto /var/log/mosquitto /opt/zram/log.bind/mosquitto
systemctl start mosquitto.service

Create /lib/systemd/system/mosquitto.service.d/override.conf to contain

[Unit]
After=network-online.target zram-config.service
Wants=network-online.target zram-config.service
5 Likes

Thanks for reply! Seems to work now. There still is a warning, but Mosquitto has started. Following the advice to restart the servis, the warning is gone, but comes back after a reeboot. Anything to worry about?

[13:24:01] openhabian@openhab2neu:~$ systemctl status mosquitto.service
Warning: The unit file, source configuration file or drop-ins of mosquitto.service changed on disk. Run 'sy
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
   Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/mosquitto.service.d
           └─override.conf
   Active: active (running) since Wed 2020-11-04 13:20:08 CET; 3min 55s ago
     Docs: man:mosquitto.conf(5)
           man:mosquitto(8)
 Main PID: 1014 (mosquitto)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/mosquitto.service
           └─1014 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Nov 04 13:20:07 openhab2neu systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Broker...
Nov 04 13:20:08 openhab2neu systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broker.

Not restart but systemctl daemon-reload.
Might still appear after but that’s probably a known cosmetic bug then.

OK, then I will leave it this way. Thanks again!

I’m not sure what to do about this now.

I am having the same problem. I am trying to migrate my Pi 3 to a new Pi 4 setup with more reliable backups and so on. So I started with a new RPi. Everything else moves across OK, rules, items, bindings. I even managed to work out how to move Node-Red and its credentials.

But the Mosquitto broker will not run. It fails on startup and I get the same error as others here about not being able to access /var/log/mosquitto/mosquitto.log.

I tried disabling zram (is this related to the cause?) and I’ve tried reinstalling Mosquitto with the same error as others again

There was an error or interruption during the execution of: │
│ “20 | Optional Components”

I’ve read through this thread and I’m not sure if we’ve found the answer. The more I muck about with trying different things, the further away from a clean standard installation I get and I worry if I’m breaking something else or future upgrades.

This is a device that controls things I use every day (wife not happy if something fails) so I prefer to keep to stable packages with as little deviation from standard setups as possible. I’m not a beginner with Openhab but I am no Linux or RPi expert so I’m just following people who know more than me.

Does anyone have a definitive summary view on why a clean installation of the latest Openhabian downloadable image onto a 16GB card installed in a brand new 2GB Pi4 cannot run Mosquitto? Better still, a way to make it work without making my system “non-standard” and perhaps not upgradeable. Even better, is there a fix coming for the standard Openhabian download?

Post #41 does not work for you ?

That’s what I added as a fix to openHABian, too. So if you install from scratch it should work right away. Just make sure you use the master branch to install (default is stable).

Ah - super. That’s what I was looking for. Many thanks

I was a bit concerned that if I make a structural change it might get undone on the next update and then mission-critical stuff like my entire heating system falls over! I’m a bit reluctant to go creating new directories and changing ownerships to make something work but now I know you’re right on top of it and it is being incorporated in later versions too then I am happy.

I’ll make the change tonight and hopefully I’m all good

Many thanks for the reply Markus

Can confirm: Installing mosquitto from the setup menu (sudo openhabian-config) works perfectly, set up several devices, all in proper working order. Reboot, no mosquitto. Manually restarting it results in authentication errors from the OH bridge thing. So something is definitely up here.

Update: It turns out the MQTT bridge was not configured correctly, although it boggles my mind how it worked on initial installation but not after reboot. At any rate, adding username/password to the thing configuration resolves the issue. Although the restart issue still remains, but that’s easy enough to hack around.

1 Like

Can confirm what ? Which openHABian branch did you install and when ? Did you check if the code from post 41 is present already ?

Can confirm what’s in the post right above you: Mosquitto installs from openhabian-config, works fine until reboot/restart. Post 41 code doesn’t fix anything.

openHAB Distribution Version Information

build-no : Release Build
online-repo : https://openhab.jfrog.io/openhab/libs-release

Repository Version

openhab-distro : 2.5.4
openhab-core : 2.5.0
openhab1-addons : 1.14.0
openhab2-addons : 2.5.4
karaf : 4.2.7

I realize this isn’t a “help desk” (as seems to be pointed out quite often here), just letting folks know the problem still exists.

Well AFAIK you’re the only one with this problem. You didn’t answer which openHABian branch you use. Does journalctl -xu mosquitto.service give any hint ?
openHAB version is not of interest and I don’t know what an “OA bridge” is so can’t tell if that’s related.
I doubt you run a OH core 2.5.0. Either way, that’s pretty old. Is your openHABian installation even buster based ? Have you ever upgraded openHABian OS packages (menu 02) ?
You should move to openHABian master and could try to uninstall and reinstall zram then eventually reinstall mosquitto.

Update: Discovered the problem: In addition to the ‘:’ character, there are apparently other prohibited password characters not enumerated in the mosquitto_passwd manpage. One of these is apparently ‘$’. Don’t bother using it in your password; authentication will fail.

Here is what is misleading: For whatever reason, when mosquitto is first installed from openhabian-config, access is set to ‘allow_anonymous true’. This allows any publisher/subscriber to connect, even though it might appear that authentication is being used. If the mosquitto daemon is restarted, allow_anonymous reverts to whatever is in the .conf file (false by default).

Obviously not an OH issue, but might still cause some issues due to lack of documentation.

Original post: It was installed from one of the pre-built OpenHABian images, probably mid-2019. I really can’t speak for the accuracy of the version info that’s installed with OpenHABian; I would assume it is at least close to be correct. At any rate, I doubt it’s an OH issue, so it probably has nothing to do with the OpenHABian branch that the image was built from.

If I find a solution I’ll post here to help others who might run into this problem.

Thanks Marcus for your prompt help. I suffered the same issue with a new install of the openhabian image on RPi3b.
Following your instructions, repeated below for those that need it too, everything works as it should, no errors:

"mkdir -p /var/log/mosquitto /opt/zram/log.bind/mosquitto
chown mosquitto /var/log/mosquitto /opt/zram/log.bind/mosquitto
systemctl start mosquitto.service

Create /lib/systemd/system/mosquitto.service.d/override.conf to contain

[Unit]
After=network-online.target zram-config.service
Wants=network-online.target zram-config.service
"
Thanks for your help.

Hello! Post 41 solved this issue for me after fresh openhabian install with latest 1.6 openhabian
Thank you!

I was having a similar issue. After installing Mosquitto using openhabian-config, everything seemed to work fine. But after doing some troubleshooting to get MQTT working, Mosquitto stopped working. I tried to find log files, run files, etc., but couldn’t find any indication there was a working version on the Pi (3B+). I tried reinstalling it a few times (as per the instructions) - no go. I tried removing it with apt and reinstalling with openhabian-config - same issue. Finally, I removed it and reinstalled it with apt - it is working again, well kind-of. Being my first iteration of MQTT, I’m having other issues, but at least the broker is online.

I got the same problem. Mosquitto worked well directly after install but after reboot it stopped working. I don’t know anything about Linux. The last three years I somewhat managed to use openhab using the config files. I was happy when openhabian came around and you didn’t have to be a linux-expert to use openhab. Coming around to version 2.5 on my raspberry 4, I tried upgrading my setup. Through much trial and error I managed to write some things files, which, due to the lack of documentation, is really difficult. When I wanted to restart and installed openhab using the openhabian installer, I encountered the same problem as others in this thread. I uninstalled the zram using the openhabian config, but this didn’t help. What should I do?

PS: Suggesting I check some xyz-config file isn’t helpful, because I don’t understand the linux system.

This problem is back on a fresh install of OH3.0 on RPI3. It is fixed by the steps in post #41

I don’t know how to report this to the devs that are debugging OH3. Can somebody do that for me or point the way?

But make sure you understand what you talk about to select the proper addressee.
Mosquitto isn’t part of OH3.

It is part of the openHABian Configuration Tool, and somehow it doesn’t install correctly, where it was working in previous versions.

Thanks for you answer I will file a bug!

Bug reports are only useful/can only be worked upon when they show the problem/misbehavior happen so provide a log showing this and do not forget to describe your starting point.
Set debugmode=maximum in openhabian.conf and record the required output.