An open source message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1
68
Mosquitto is an open source (BSD licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1.
Sample config file: mosquitto.conf
pwfile is managed by mosquitto_passwd.capath is needed.cafile is needed.Important
It is important to use different certificate subject parameters for your self-signed CA, server and clients.
$ mkdir -p data/{etc,var,log}
$ chmod -R 777 data
$ touch data/etc/mosquitto.conf data/etc/pwfile
$ vim data/etc/mosquitto.conf
$ docker compose up -d
$ docker compose exec mosquitto sh
>>> cd /etc/mosquitto
>>> mosquitto_passwd -b pwfile username password
>>> cat pwfile
username:$6$IuF7JUzS1k/QoF3y$YpiClom7/==
>>> exit
$ docker compose kill -s SIGHUP
$ tails -f data/log/mosquitto.log
2022-12-08T06:59:00: mosquitto version 1.4.8 (build date 2016-05-16 14:17:19+0000) starting
2022-12-08T06:59:01: Config loaded from /etc/mosquitto/mosquitto.conf.
2022-12-08T06:59:02: Opening ipv4 listen socket on port 8883.
2022-12-08T06:59:03: Opening ipv6 listen socket on port 8883.
2022-12-08T06:59:04: New connection from 192.168.31.102 on port 8883.
2022-12-08T06:59:05: New client connected from 192.168.31.102 as mosqsub/38158-Kevins-Ma (c1, k60).
2022-12-08T06:59:06: New client connected from 192.168.31.102 as mosqpub/38324-Kevins-Ma (c1, k60).
2022-12-08T06:59:07: Client mosqpub/38324-Kevins-Ma disconnected.
$ mosquitto_sub -d -h 192.168.31.231 -p 8883 --cafile ca.crt --insecure -u username -P password -t hello
Client mosqsub/38158-Kevins-Ma sending CONNECT
Client mosqsub/38158-Kevins-Ma received CONNACK
Client mosqsub/38158-Kevins-Ma sending SUBSCRIBE (Mid: 1, Topic: hello, QoS: 0)
Client mosqsub/38158-Kevins-Ma received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/38158-Kevins-Ma sending PINGREQ
Client mosqsub/38158-Kevins-Ma received PINGRESP
received PUBLISH (d0, q0, r0, m0, 'hello', ... (5 bytes))
world
Client mosqsub/38158-Kevins-Ma sending PINGREQ
Client mosqsub/38158-Kevins-Ma received PINGRESP
$ mosquitto_pub -d -h 192.168.31.231 -p 8883 --cafile ca.crt --insecure -u username -P password -t hello -m world
Client mosqpub/38324-Kevins-Ma sending CONNECT
Client mosqpub/38324-Kevins-Ma received CONNACK
Client mosqpub/38324-Kevins-Ma sending PUBLISH (d0, q0, r0, m1, 'hello', ... (5 bytes))
Client mosqpub/38324-Kevins-Ma sending DISCONNECT
Note
With correct SAN (Subject Alternative Name), option `--insecure` is not needed any more.
Content type
Image
Digest
sha256:3ef02c6ef…
Size
9.5 MB
Last updated
8 days ago
docker pull easypi/mosquitto