Mosquitto constantly restarting

Hi guys,

me again with another error :sweat:. So I´m running HA on a RPi3 installed by die AIO-Installer. HA seems to work perfectly, the problem is with Mosquitto. It´s restarting every few minutes. I´m running the AIO default config but I added a bridge to CloudMQTT. The error occures with and without the bridge settings.

Aug 20 19:17:01 HomeAssistant systemd[1]: mosquitto.service start operation timed out. Terminating.
Aug 20 19:17:01 HomeAssistant mosquitto[22888]: 1471713421: Error in poll: Interrupted system call.
Aug 20 19:17:01 HomeAssistant mosquitto[22888]: 1471713421: mosquitto version 1.4.9 terminating
Aug 20 19:17:01 HomeAssistant mosquitto[22888]: 1471713421: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
Aug 20 19:17:01 HomeAssistant systemd[1]: Failed to start Mosquitto MQTT Broker daemon.
Aug 20 19:17:01 HomeAssistant systemd[1]: Unit mosquitto.service entered failed state.
Aug 20 19:17:03 HomeAssistant systemd[1]: mosquitto.service holdoff time over, scheduling restart.
Aug 20 19:17:03 HomeAssistant systemd[1]: Stopping Mosquitto MQTT Broker daemon...
Aug 20 19:17:03 HomeAssistant systemd[1]: Starting Mosquitto MQTT Broker daemon...
Aug 20 19:17:03 HomeAssistant mosquitto[22953]: 1471713423: mosquitto version 1.4.9 (build date 2016-06-18 14:51:33+0200) starting

So does anybody have a clue?:disappointed:

I would try starting mosquitto without a configuration file and see if it happens. If no then it’s most likely something in the configuration file.
You could also try reinstalling the mosquitto package to be certain that it’s not a corrupted file or simliar.

When Mosquitto is installed by the Home Assistant All in One installer, the included Mosquitto configuration will keep it from running until you’ve set up a user/password combination with the mosquitto_passwd command.

Have a look at the video here to see how that works.

I already added a Username and Password for Mosquitto but I ran the initial config. So I build my own config with just the following in it:

pid_file /var/lib/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/

allow_anonymous false
password_file /etc/mosquitto/pwfile
listener 1883

#Bridge
connection cloudmqtt
try_private false
address ....
start_type automatic
remote_username ....
remote_password ....
clientid ha-bridge
notifications false
topic ....

And after a while I still get:

Aug 23 20:49:50 HomeAssistant systemd[1]: mosquitto.service start operation timed out. Terminating.
Aug 23 20:49:50 HomeAssistant mosquitto[724]: 1471978190: Error in poll: Interrupted system call.
Aug 23 20:49:50 HomeAssistant mosquitto[724]: 1471978190: mosquitto version 1.4.9 terminating
Aug 23 20:49:50 HomeAssistant mosquitto[724]: 1471978190: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
Aug 23 20:49:50 HomeAssistant systemd[1]: Failed to start Mosquitto MQTT Broker daemon.
Aug 23 20:49:50 HomeAssistant systemd[1]: Unit mosquitto.service entered failed state.
Aug 23 20:49:52 HomeAssistant systemd[1]: mosquitto.service holdoff time over, scheduling restart.
Aug 23 20:49:52 HomeAssistant systemd[1]: Stopping Mosquitto MQTT Broker daemon...
Aug 23 20:49:52 HomeAssistant systemd[1]: Starting Mosquitto MQTT Broker daemon...

EDIT:
@Landrash Reinstalled it. Started with default config:

Aug 23 22:17:05 HomeAssistant systemd[1]: Starting Mosquitto MQTT Broker daemon...
Aug 23 22:18:36 HomeAssistant systemd[1]: mosquitto.service start operation timed out. Terminating.
Aug 23 22:18:36 HomeAssistant systemd[1]: Failed to start Mosquitto MQTT Broker daemon.
Aug 23 22:18:36 HomeAssistant systemd[1]: Unit mosquitto.service entered failed state.
Aug 23 22:18:38 HomeAssistant systemd[1]: mosquitto.service holdoff time over, scheduling restart.
Aug 23 22:18:38 HomeAssistant systemd[1]: Stopping Mosquitto MQTT Broker daemon...
Aug 23 22:18:38 HomeAssistant systemd[1]: Starting Mosquitto MQTT Broker daemon...

What do you get when you run the command sudo systemctl status mosquitto ? It should tell you what’s wrong…

Seems to be running for the moment until it suddenly restarts for no reason.

mosquitto.service - Mosquitto MQTT Broker daemon
   Loaded: loaded (/etc/systemd/system/mosquitto.service; enabled)
   Active: activating (start) since Tue 2016-08-23 23:55:56 CEST; 1min 0s ago
  Control: 7019 (mosquitto)
   CGroup: /system.slice/mosquitto.service
           ââ7019 /usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Did you ever solve this? I think I have the same problem. I don’t see anything in the Home Assistant log and I don’t know where to check the Mosquitto log, but if I manually subscribe to a topic like this:
mosquitto_sub -d -u user -P pass -t test
I keep getting disconnected. I also trying a windows client and an Android client and they have the same issue. It happens about once per minute.

No not really. I´m running CloudMQTT now since i only use it for Owntracks. But still can´t bridge it to my local Mosquitto because of that reason. So yeah i´m stucked to CloudMQTT.

I just noticed that there is an open issue on github that sounds very similar:

The solution seems to be:
Add the following lines to mosquitto.conf wil fix the issue:
pid_file /var/run/mosquitto.pid
user mosquitto

I have not tried yet, but I will as soon as I get some time.

2 Likes

Yesterday I’ve reinstalled HA with the All-In-One Installer and the same issue…

And the solution for me was to uninstall the mosquito and install the latest version. For that, I’ve used http://www.instructables.com/id/Installing-MQTT-BrokerMosquitto-on-Raspberry-Pi/