MQTT doesnt restart on openhab3 reboot

  • Platform information: Raspberry 4
    • Hardware: Raspberry Pi 4
    • OS: Raspian
    • openHAB version: 3
  • Issue of the topic: everytime I restart my openhab, MQTT doesnt gets started and I reinstall using openhab-config to get it started again.

This setup was installed created around a month back, so I assume i have all latest versions. I have this mqtt problem right form the begining

1 Like

To confirm - are you running openhabian?

Yes, I am using openhabian.

What do get when your run systemctl status mosquitto
in ssh

Maybe this will do the trick
sudo systemctl enable mosquitto

I am on my way home. Will try this in an hour and let you know. Thanks in advance.

Hi,
“sudo systemctl enable mosquitto” didnt work.

This is what I get when I run systemctl status mosquitto

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 Sat 2021-03-06 08:32:56 IST; 30min ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Main PID: 1010 (code=exited, status=1/FAILURE)

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

Looks like some config error.
What’s your mqtt config?

This post sums it up quite well re mqtt installation.

I did the instalatin exactly as mentioned n your link. Still same error.

Let me tell you what i did. I installed Openhab3. Then went to penhabian-config and installed mosquitto from the install otional components option. Then i creatd the broker thing etc etc as mentind in the install document of oenhab. And it was all working properly. Until power went off. When power came back then mosquitto is not starting. Only way can get it startd is by reinstalling using the Install optional components in the openhabian-config.

So what did I do wrong? Please help


U asked about my mqtt config. what does that mean and what file I should share to you?.

Tbh i did not install mqtt via openhab as I run it on a seperaten VM.
It could also be a permission issue, i.e. during restart the permissions are somehow reset whereas openhabian might have set the right one (if i remember well, there is a permission fix option in openhabian which you could try).
Otherwise you could look into 2 config files:

  1. the mqtt config as shown here(take into account that openhabian might use different folders?)
  2. your systemd config file for mqtt which contains the startup run command and user:group: check this location: /lib/systemd/system/mosquitto.service (again, might be different on your system but usually that’s the directory)

See if this post, and thread in general, helps you

1 Like

Thanks @pretheepkp for posting this question and @hafniumzinc for posting a link to the solution!
I have been experiencing the same issue (openHABian with openHAB 3 on RPi 4) for quite some time now but didn’t have time to look into it.

Following 2 commands from the link above fixed it for me:

mkdir -p /var/log/mosquitto /opt/zram/log.bind/mosquitto
chown mosquitto /var/log/mosquitto /opt/zram/log.bind/mosquitto
2 Likes

Thx, that solved it for me as well
 zram seems to cause some trouble here and there. i already hat to restart it because the log-viewer does not work cause of it.