Mosquitto MQTT broker problem - keeps restarting

Hello,

I'm trying to install a (Docker) Mosquitto MQTT broker (see https://docs.arduino.cc/tutorials/portenta-x8/datalogging-iot).
However, the Mosquitto broker after running the docker-compose file keeps restarting?
Anyone an idea where this problem can come from? BTW, I have several Mosquitto brokers running on other platforms (locally and in the cloud) without any problem.

Thanks,
Guy

Probably too late, but maybe helpful to somebody:

When I run the "docker-compose up" without the "-d", an error message is displayed, indicating that the config file is not found.

Using these paths in the "docker-compose.yml" helped:

-/var/rootdirs/home/root/mqtt/config:/mqtt/config
-/var/rootdirs/home/root/mqtt/data:/mqtt/data
-/var/rootdirs/home/root/mqtt/log:/mqtt/log

Now the broker is running without restarting.

The success is only partial though, as I can't connect to it. Tried the suggested MQTTBox and Node-RED, both show connection error.

Actually the previous idea is wrong. The path is false, this causes docker to use a default config, hence the lack of error messages, and this is why it is not restarting continuously.
But it will not use the settings we defined in our config file.

After some experimenting I think I've got the solution. This tutorial helped:
MQTT With Home Assistant Using Docker & Mosquitto - HomeTechHacker

A couple of corrections:

  • The path needs to be changed to: "mkdir -p /var/rootdirs/home/fio/mosquito/config".

  • When adding the password protection, the "allow_anonymous true" has to be changed to false

The original method with the docker-compose seems much more elegant, I would appreciate if somebody could explain how it should be changed to make it work

I was able to resolve this by mounting the volumes in my docker compose (as above)

  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    restart: always
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
      - /home/usr/mosquitto/data:/mosquitto/data
      - /home/usr/mosquitto/config:/mosquitto/config
      - /home/usr/mosquitto/log:/mosquitto/log

and then created a file /home/usr/mosquitto/config/mosquitto.conf

Before that, docker logs mosquitto printed "Unable to open config file". Now it seems to be using default settings.

Hello guys,

This is José; I wrote the tutorial. The issue with the Mosquitto broker restarting has been fixed in its latest update.

The corrections were made to the following:

  • Docker compose file updated (fio user)
  • Mosquitto broker configuration file updated

Please check it and let me know if it works for you, thank you for the feedback.

1 Like