As part of my setup, I have a Mosquitto MQTT broker running in a Docker container. This has been an excellent setup, but a couple of days ago, it failed completely - turns out the image tag ‘latest’ had switched to 2.0.9 from 1.6.x, and there were some breaking changes!
The fix was relatively simple in the end, but took me a while to figure out, so I thought I’d document it here in case anyone else faces the same.
Important note - I don’t have any type of authentication in my MQTT network - this is done for simplicity when messing around with other devices, and because it’s in an isolated sub-net - if you use security, you’ll likely need some additional lines as well.
The failure symptom was that my broker and all MQTT devices went offline - with the broker throwing the error below:
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /ip_address:1883
To fix, you need to add a couple of lines to the mosquitto.conf file in your broker:
#Original_file
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
#New_lines_below
listener 1883
allow_anonymous true
#user root is needed if installing direct - doesn't appear to be needed if in docker
user root
The reason these are needed is documented here.
Hope this is helpful to someone!