Mosquitto errors


(Angelos) #18

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

user mosquitto
port 1883

The Broker should become active (running)

If this works, start adding back the other options in your new mosquitto.conf, like:

pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
allow_anonymous false
password_file /etc/mosquitto/passfile

(Brian Paulmann) #19

hi i removed mosquitto.conf and created a new one only

user mosquitto
port 1883

and get this :slight_smile:


(Angelos) #20

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… :sunglasses:


(Brian Paulmann) #21

now my conf file is

user mosquitto
port 1883
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
allow_anonymous false
password_file /etc/mosquitto/passfile

and i have run chown

but


(Angelos) #22

disable persistence (set persistence false) and restart the broker. It should become active (running)
check the directory /var/lib/mosquitto/ for the permissions and if any file was created in there

… and start looking for a new SD Card :slight_smile: (it may have data corruption problems…)


(Brian Paulmann) #23

stil it dont become active


(Angelos) #24

ok… remove both lines that have something to do with persistence:

persistence true
persistence_location /var/lib/mosquitto/

If this doesn’t work… use process of elimination (remove more lines from the config file… the only line that you really need to bring up the broker is the pid_file config option)


(Brian Paulmann) #25

now i got

user mosquitto
port 1883
pid_file /var/run/mosquitto.pid
persistence true
allow_anonymous false
password_file /etc/mosquitto/passfile


(Angelos) #26

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 :slight_smile:


(Brian Paulmann) #27


(Angelos) #28

Looks good

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 :slight_smile:
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.


(Brian Paulmann) #29

how do i make the item for the sonoff th16 temp value and the humidity the setup of the sonoff is


(Brian Paulmann) #30

i have a new sd card but how do i move from the old one and to the new one can i do that whitout setting every things up again


(Brian Paulmann) #31

the powersupply and sdcard are from raspberry pi and it is only 3 month old


(Angelos) #32

Check the forum for similar posts and if you get stuck, ask for help :wink:

Some hints:




there are many more

You could clone it (http://www.makeuseof.com/tag/easily-clone-your-sd-card-for-trouble-free-raspberry-pi-computing/)
I usually prefer to start clean and configure my system from scratch (but that’s just me)

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).


(Brian Paulmann) #33

1000 thanks for your very big help, I appreciate that very much, this is all new to me


(SiHui) #34

If this is still an open issue take a look here:


(Brian Paulmann) #35

Hi again Dim

can I somehow see in mosquitto if it receives data from the Sonoff


(Angelos) #36

Hi Brian,

Yes, you can use the subscribe command to monitor the topic that sonoff is publishing messages to.

mosquitto_sub -u openhab -P habopen -t <sonoff_topic> -v

If you don’t know the topic that sonoff uses, you can use (#) for the topic or use a client for MQTT (like: MQTT.fx and subscribe to all topics (#))

To see if the sonoff client is connecting, you could also add the following in your mosquitto.conf:

connection_messages true

This will log the connection in /var/log/mosquitto/mosquitto.log. But not the topic and/or the message.


(Matthias Reinagl) #37

Hi,

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?

Thanks
Matthias