Quick MQTT

Posted on September 2, 2022
Tags: codeetc

create a mosquitto.conf

0.0.0.0 allows us to hit the MQTT inside docker from the LAN. Without it, no one can access it, not even the machine its running on since it has been containered.

persistence false
log_dest stdout
allow_anonymous true
connection_messages true
listener 1883 0.0.0.0
docker run -it -p 1883:1883 -p 9001:9001 -v $HOME/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
#consumer 
mosquitto_sub -h 127.0.0.1 -t topicX
#producer 
mosquitto_pub -h 127.0.0.1 -t topic -m "Hello
" -d