MQTT Broker

Hey, I have moskito installed and my MQTT Broker wos working perfectly but it suddently stoped working any idea?

Have you done any updates? Latest versions of Mosquitto require some configuration changes.

Otherwise, presumably you’ve checked that Mosquitto is actually still running?

how can i check if mosquito is running?

I have no idea how your system is setup.

If you’re using Linux, and you installed Mosquitto via apt, then try:

sudo systemctl status mosquitto

i have openhabian, do i use what you sent or is it something diferent?

just try it. Yes, you can use that command with openhabian.

These is what i get when running the command. what does these mean?

mosquitto is not running.
You may try to restart it: sudo systemctl restart mosquitto
If it fails again have a lock into /var/log/mosquitto/mosquitto.log if there is any hint about why it stopped running.


any idea?

Run both suggested commands prefixed with sudo

Screenshot 2021-12-11 225904

You forgot the leading /. Try sudo cat /var/log/mosquitto/mosquitto.log
Don’t forget to check sudo journalctl -xe

openhabian@openhabian:~ $ sudo cat /var/log/mosquitto/mosquitto.log
cat: /var/log/mosquitto/mosquitto.log: No such file or directory
openhabian@openhabian:~ $ sudo journalctl -xe
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit UNIT has finished successfully.
--
-- The job identifier is 11.
Dec 11 23:46:39 openhabian systemd[12463]: Reached target Sockets.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit UNIT has finished successfully.
--
-- The job identifier is 6.
Dec 11 23:46:39 openhabian systemd[12463]: Reached target Basic System.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit UNIT has finished successfully.
--
-- The job identifier is 2.
Dec 11 23:46:39 openhabian systemd[12463]: Reached target Default.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit UNIT has finished successfully.
--
-- The job identifier is 1.
Dec 11 23:46:39 openhabian systemd[12463]: Startup finished in 175ms.
-- Subject: User manager start-up is now complete
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The user manager instance for user 1000 has been started. All services queued
-- for starting have been started. Note that other services might still be starting
-- up or be started at any later time.
--
-- Startup of the manager took 175114 microseconds.
Dec 11 23:46:39 openhabian systemd[1]: Started User Manager for UID 1000.
-- Subject: A start job for unit user@1000.service has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit user@1000.service has finished successfully.
--
-- The job identifier is 14243.
Dec 11 23:46:39 openhabian systemd[1]: Started Session 538 of user openhabian.
-- Subject: A start job for unit session-538.scope has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit session-538.scope has finished successfully.
--
-- The job identifier is 14309.
Dec 11 23:46:51 openhabian sudo[12872]: openhabian : TTY=pts/0 ; PWD=/home/openhabian ; USER=root ; COMMAND=/usr/bin/cat /var/log/mosquitto/mosquitto.log
Dec 11 23:46:51 openhabian sudo[12872]: pam_unix(sudo:session): session opened for user root by openhabian(uid=0)
Dec 11 23:46:51 openhabian sudo[12872]: pam_unix(sudo:session): session closed for user root
Dec 11 23:46:58 openhabian sudo[12880]: openhabian : TTY=pts/0 ; PWD=/home/openhabian ; USER=root ; COMMAND=/usr/bin/cat /var/log/mosquitto/mosquitto.log
Dec 11 23:46:58 openhabian sudo[12880]: pam_unix(sudo:session): session opened for user root by openhabian(uid=0)
Dec 11 23:46:58 openhabian sudo[12880]: pam_unix(sudo:session): session closed for user root
Dec 11 23:47:07 openhabian sudo[12897]: openhabian : TTY=pts/0 ; PWD=/home/openhabian ; USER=root ; COMMAND=/usr/bin/journalctl -xe
Dec 11 23:47:07 openhabian sudo[12897]: pam_unix(sudo:session): session opened for user root by openhabian(uid=0)

openhabian@openhabian:~ $

these is what i got

That is strange:

  • in case mosquitto is installed there should be a file in directory /var/log/mosquitto
  • in case mosquitto has startup problems that should be mentioned in the journalctl output but it is not

Out of curiosity: did you just restart openhabian before posting the output of journalctl ? I am wondering why there is no output for mosquitto.

I didn’t restart openhabian

ok. Let’s do some other checks:
Which version is installed: dpkg -l | grep mosquitto
Does a log file/directory for mosquitto exist: ls -l /var/log /var/log/mosquitto 2>/dev/null |grep mosquitto

Based on the previous analysis it looks like there would be no log directory for mosquitto.
The above commands do a few further checks. In case the first one does not show that mosquitto is installed you need to install it ( again ). In case the log directory/file for mosquitto is not shown you may need to install it again.

1 Like


these is what i got.

ok.
There is the directory /var/log/mosquitto. But it is owned by root:root instead of mosquitto:mosquitto.
You can use: sudo chown mosquitto:mosquitto /var/log/mosquitto
to repair that. After that try: sudo systemctl restart mosquitto
In case mosquitto still does not start there might be further problems with regard to permissions.
Check if the log file then exists and contains further information.
I assume that you use ZRAM. Check if mosquitto starts again after restarting OH. It could be that the permssions are changed back after you repaired them. In that case you may have to stop/deinstall ZRAM; repair the ownership of /var/log/mosquitto and start/install ZRAM again.

EDITed: sorry the last argument in the chown command was missing

Screenshot 2021-12-12 180251

sorry, the last argument in the chown command was missing. I corrected that in my previous post.