Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » Certbot (Lets Encrypt) leaves Mosquitto service dead(After the periodic certbot renewal, Mosquitto is left in the Active/Exited state)
Certbot (Lets Encrypt) leaves Mosquitto service dead [message #1843238] Wed, 21 July 2021 09:27 Go to next message
Kenny Millar is currently offline Kenny MillarFriend
Messages: 4
Registered: August 2020
Location: Sotland, UK
Junior Member

I have a real Ubuntu Server hosted in an ISP
It runs a few websites of mine plus a mosquitto broker.

I use certbot from Lets Encypt to autorenew my certificates.
From time to time it renews the mosquitto certs. When it does, it calls this post-hook command:
systemctl restart mosquitto


And my mosquitto service gets left in this state:

kenny@IS-83108:~$ sudo systemctl status mosquitto
* mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated)
   Active: active (exited) since Tue 2021-07-20 18:15:11 BST; 15h ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/mosquitto.service

Jul 20 18:15:11 IS-83108 systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Jul 20 18:15:11 IS-83108 mosquitto[22547]:  * Starting network daemon: mosquitto
Jul 20 18:15:11 IS-83108 mosquitto[22547]:    ...done.
Jul 20 18:15:11 IS-83108 systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
kenny@IS-83108:~$ 


And the mosquitto log contains this at the tail:
1626801311: mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) starting
1626801311: Config loaded from /etc/mosquitto/mosquitto.conf.
1626801311: Opening ipv4 listen socket on port 1883.
1626801311: Error: Address already in use
1626801304: New client connected from 188.29.234.133 as 24349eef-a848-4464-81e6-9dceea4bafba (c1, k60).
1626801304: Client 24349eef-a848-4464-81e6-9dceea4bafba disconnected.
1626801311: mosquitto version 1.4.15 terminating


Then I have to manually stop and start the service.
Any ideas?


-Kenny Millar
Re: Certbot (Lets Encrypt) leaves Mosquitto service dead [message #1843261 is a reply to message #1843238] Wed, 21 July 2021 16:02 Go to previous messageGo to next message
Roger Light is currently offline Roger LightFriend
Messages: 90
Registered: September 2013
Member
```
1626801311: Error: Address already in use
```

I would say that the problem lies here, but then the next line shows a client connecting so perhaps it isn't. I'm not sure what to suggest - I would note that 1.4.15 is pretty old now though.
Re: Certbot (Lets Encrypt) leaves Mosquitto service dead [message #1843262 is a reply to message #1843261] Wed, 21 July 2021 16:10 Go to previous message
Kenny Millar is currently offline Kenny MillarFriend
Messages: 4
Registered: August 2020
Location: Sotland, UK
Junior Member

Hi - thanks for the reply!
I managed to work around this issue by editing the mosquitto entry in /etc/init.d

In the "restart" section I added a sleep 2 like this:
restart)
	if init_is_upstart; then
	    exit 1
	fi
	log_daemon_msg "Restarting network daemon:" "mosquitto"
	if start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile ${PIDFILE}; then
	    rm -f ${PIDFILE}
	fi
	sleep 2
	if start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} -- -c /etc/mosquitto/mosquitto.conf ; then
	    log_end_msg 0
	else
	    log_end_msg 1
	fi
	;;


I'm aware that is a bit of a hack - and is probably not the correct solution. However I will keep looking for a permanent solution and will try upgrading the mosquitto package too.

Thanks again!


-Kenny Millar
Previous Topic:High Resources Mosquitto Pub
Next Topic:Publishing to unknown client?
Goto Forum:
  


Current Time: Thu May 02 18:47:03 GMT 2024

Powered by FUDForum. Page generated in 0.03962 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top