Check the permissions of the /var/lib/mosquitto/ directory.
It should be owned by the user mosquitto.
To fix this: chown -R mosquitto:mosquitto /var/lib/mosquitto
Check if the file mosquitto.db has been created in there.
Otherwise…It may be a problem with your mosquitto.conf file… (some syntax error or something similar)
back it up and remove it from /etc/mosquitto/ folder put in the following simple options in a new one and try to systemctl restart mosquitto
The Broker should become active (running)
If this works, start adding back the other options in your new mosquitto.conf, like:
It’s up and running (but without authentication)
So… the problem must be the persistence_location (/var/lib/mosquitto/)
Change the ownership of that directory: chown -R mosquitto:mosquitto /var/lib/mosquitto
and put back the options in your mosquitto.conf and restart the broker
It should work…
now it’s running and you can test the sub & pub commands.
It seems to me that something is wrong with your /var/lib/mosquitto/ directory. The Broker could not write (and read?) from the persistence file /var/lib/mosquitto/mosquitto.db
It may be that your SD Card is not very happy and needs a change
You can progress to the next steps
Also, your sonoff should be connecting now to the MQTT Broker… check that also
I would worry about the SD Card if I was you
Maybe it’s better to get a new one and start with a clean openHABian deployment
Also, make sure that you have a good quality USB Power Supply feeding the Raspberry Pi (I use an “official” PSU)
A proper power feed makes a big difference and keeps your rPi stable and your SD Card happy.
Corruption can occur due to power loss or fluctuation (while rPi is writing data)
Something was not working with your /var/lib/mosquitto directory…
Did you check permissions and if any file was created in there?
If yes: the file-system could be corrupted (it happens).
I finally got my mosquitto to cooperate with openHAB and get messages forwarded from OwnTracks.
But Mosquitto doesn’t seem to run stable over a longer period.
I run version 1.4.14.
And after a couple of days there is no log-file anymore in /var/log/mosquitto - Although I just checked with
systemctl status mosquito
and get the status “active (running)”. And nothing gets sent anymore. When I restart the service everything is back to normal again (for a couple of days).
Any hints what I can check to see what happens?