MQTT stops working after reboot
Posted: Sat 01 Mar 2025 2:25 pm
I ran into some issues when connecting my CMX to Home Assistant via MQTT.
I'm running the latest CMX version on a Raspberry Pi 5, which also runs Home Assistant OS in a proxmox VM. I have a DIY NAS connected to the Pi as well shared via samba, but for some reason I can't access it from my Windows machines after around a week (bear with me, this is an important piece to the puzzle). Rebooting fixes this issue, so the Pi does a scheduled reboot every night at 5:00 after the HA backup.
After setting MQTT up initially, everything works fine up until the reboot at night. Then the sensors become unavailable and no data is coming in any more. Rebooting the whole system does not fix it. I switched from Mosquitto to EMQX, but it showed the exact same behavior. I was hoping to get some more insight with EMQX, but after the failure there was no sign of CMX even being connected. So no logs, no errors, nothing.
During a manual reboot I noticed that CMX is up and running a few seconds later, while HA takes a few minutes (running in a VM and all that). So I wondered if that might be the problem somehow and restarted the cumulusmx service. Lo and behold, everything came back to life and data started pouring in again. To verify I repeated the whole process with longer time between rebooting and restarting the service with exactly the same outcome.
It seems like when CMX starts, it tries to connect to the MQTT broker, fails and simply does not try again?
I'll try with scheduling a service restart 5 minutes after the reboot for now. I know it's not an elegant solution, but I didn't find an easy way to delay the start of a service on boot either.
I figured I report the issues here as it seems like unintended behavior.
Sorry if this is just plain stupidity on my part. I'm quite proficient with Windows, but when it comes to Linux half of the time I don't even know what I'm doing
Even less so with MQTT. So please, no hesitation in pointing out stupidity on my part 
P.S.: I really love the piece of software all of you have created
I'm running the latest CMX version on a Raspberry Pi 5, which also runs Home Assistant OS in a proxmox VM. I have a DIY NAS connected to the Pi as well shared via samba, but for some reason I can't access it from my Windows machines after around a week (bear with me, this is an important piece to the puzzle). Rebooting fixes this issue, so the Pi does a scheduled reboot every night at 5:00 after the HA backup.
After setting MQTT up initially, everything works fine up until the reboot at night. Then the sensors become unavailable and no data is coming in any more. Rebooting the whole system does not fix it. I switched from Mosquitto to EMQX, but it showed the exact same behavior. I was hoping to get some more insight with EMQX, but after the failure there was no sign of CMX even being connected. So no logs, no errors, nothing.
During a manual reboot I noticed that CMX is up and running a few seconds later, while HA takes a few minutes (running in a VM and all that). So I wondered if that might be the problem somehow and restarted the cumulusmx service. Lo and behold, everything came back to life and data started pouring in again. To verify I repeated the whole process with longer time between rebooting and restarting the service with exactly the same outcome.
It seems like when CMX starts, it tries to connect to the MQTT broker, fails and simply does not try again?
I'll try with scheduling a service restart 5 minutes after the reboot for now. I know it's not an elegant solution, but I didn't find an easy way to delay the start of a service on boot either.
I figured I report the issues here as it seems like unintended behavior.
Sorry if this is just plain stupidity on my part. I'm quite proficient with Windows, but when it comes to Linux half of the time I don't even know what I'm doing
P.S.: I really love the piece of software all of you have created