Mosquitto errors

switch to root first with:

sudo su

and then try again :slight_smile:
(or put sudo in front of every command since the user pi doesn’t have access to several system directories)

i stil get

and this is for systemctl status mosquitto

I am scratching my head … :slight_smile: It should have worked…

Try the following:

apt-get update
apt-get upgrade mosquitto

also: check the systemctl status mosquitto to see what it says…
Somehow your mosquitto server is not working…?

it’s broken… It shows “active (exited)” when it should be showing “active (running)”…
Check the /var/log/mosquitto/mosquitto.log for errors
try to apt-get update and then apt-get upgrade mosquitto
If this doesn’t help: apt-get remove mosquitto and then apt-get install mosquitto

1 Like

i have now done apt-get remove mosquitto and then apt-get mosquitto and i get this status
¨

and log

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
1 Like

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

user mosquitto
port 1883

and get this :slight_smile:

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:

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

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

stil it dont become active

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)

now i got

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

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:

1 Like

1 Like

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.

1 Like

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

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

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