Page 1 of 1
MQTT failure with boot and reboot
Posted: Monday 12 October 2020 12:35
by McMelloW
Dear forumers
Code: Select all
uname -a
Linux rpi-2b 5.4.51-v7+ #1333 SMP Mon Aug 10 16:45:19 BST 2020 armv7l GNU/Linux
On this RPi-2B with Buster, I have created a mosquitto MQTT Broker.
Using <<sudo service mosquitto restart>> or stop and start work OK. But a reboot or shutdown and power-on boot, the port 1883 is still in use and I cannot start mosquitto.
I have to use sudo kill -kill <PID> to release the listener job.
What can I do to solve this problem?
Or is there a work around with a delaay in the reboot and/or shutdown?
Re: MQTT failure with boot and reboot
Posted: Monday 12 October 2020 13:45
by erem
a (re)boot kills all processes, so i conclude there must be something wrong in your mqtt start up.
what does systemctl status mosquitto tell you after reboot.
have you tried reinstalling mqtt?
Re: MQTT failure with boot and reboot
Posted: Monday 12 October 2020 14:48
by McMelloW
erem wrote: Monday 12 October 2020 13:45
what does systemctl status mosquitto tell you after reboot.
have you tried reinstalling mqtt?
It is a headless RPi only connected with an ethernet cable. Communication is done with Putty and ssh
status before reboot
Code: Select all
pi@rpi-2b:~ $ sudo service mosquitto status
? mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset
Active: active (running) since Mon 2020-10-12 14:37:30 CEST; 3s ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Main PID: 1233 (mosquitto)
Tasks: 1 (limit: 2065)
CGroup: /system.slice/mosquitto.service
??1233 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Oct 12 14:37:30 rpi-2b systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Broker...
Oct 12 14:37:30 rpi-2b systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broker.
Staus after a reboot now
Code: Select all
pi@rpi-2b:~ $ sudo service mosquitto status
? 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 Mon 2020-10-12 14:38:22 CEST; 52s ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 403 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 403 (code=exited, status=1/FAILURE)
Oct 12 14:38:22 rpi-2b systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.
Oct 12 14:38:22 rpi-2b systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Oct 12 14:38:22 rpi-2b systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.
Oct 12 14:38:22 rpi-2b systemd[1]: mosquitto.service: Start request repeated too quickly.
Oct 12 14:38:22 rpi-2b systemd[1]: mosquitto.service: Failed with result 'exit-code'.
Oct 12 14:38:22 rpi-2b systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.
pi@rpi-2b:~ $ sudo netstat -anp | grep 1883
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 382/mosquitto
tcp6 0 0 :::1883 :::* LISTEN 382/mosquitto
Sudo kill -kill 382 makes it possible to start mosquitto again (sudo kill 382 does not work correctly in ssh on my RPi)
Re: MQTT failure with boot and reboot
Posted: Monday 12 October 2020 21:37
by FireWizard
Hi @McMellow,
Could you check the contents of /lib/systemd/system/mosquitto.service
Mine looks like:
Code: Select all
[Unit]
Description=Mosquitto MQTT v3.1/v3.1.1 Broker
Documentation=man:mosquitto.conf(5) man:mosquitto(8)
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
NotifyAccess=main
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
Hopefully it is not the same as:
viewtopic.php?t=32157
Regards
Re: MQTT failure with boot and reboot
Posted: Monday 12 October 2020 23:16
by McMelloW
Hoi @FireWizard
FireWizard wrote: Monday 12 October 2020 21:37
Hi @McMellow,
Could you check the contents of /lib/systemd/system/mosquitto.service
Mine looks like:
Mine looks exact as yours. I did not touched it at all.
Did checked it already. it is not the case.
Re: MQTT failure with boot and reboot
Posted: Tuesday 13 October 2020 12:15
by erem
googling the error message yielded this
https://github.com/eclipse/mosquitto/issues/1419
downgrading mqtt may help.
to diagnose further you could try and disable starting thru systemd and check if port 1883 is still used.
from above link i read the error is caused by port 1883 already being used when systemd tries to start mqtt
keep us updated.
Re: MQTT failure with boot and reboot
Posted: Tuesday 13 October 2020 18:02
by FireWizard
Hi @McMelloW
In addition to @erem post you could have a look at: /etc/mosquitto/mosquitto.conf.
Mine looks:
Code: Select all
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
port 1883
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
#log_dest file /var/log/mosquitto/mosquitto.log
#include_dir /etc/mosquitto/conf.d
I found a post at:
https://github.com/eclipse/mosquitto/issues/882
If you go to the post: chris-008 commented on 12 Aug 2018 you will find a solution that worked for him.
You can try to comment the line with the port no 1883.
No guarantee that it is the solution, as I have seen other posts, saying it doesn't work.
But worthwhile to try, at least.
Regards
Re: MQTT failure with boot and reboot
Posted: Tuesday 13 October 2020 19:02
by McMelloW
@erem and @FireWizard.
Hey guys,
Yess...Got it working!!!
Thank you so much for your support. Used the steps from the final post from chris008 as mentioned above.
Made changes to mosquitto.service and to mosquitto.conf.
Code: Select all
sudo systemctl daemon-reload
sudo reboot now
Mosquitto is up and running.