Add labs
This commit is contained in:
127
01-basics/lab01/lab.txt
Normal file
127
01-basics/lab01/lab.txt
Normal file
@ -0,0 +1,127 @@
|
||||
= Installation und Starten eines Mosquitto Brokers
|
||||
|
||||
Nutzen Sie eine der folgenden Methoden, um
|
||||
den Mosquitto Broker lokal zu installieren und zu starten.
|
||||
|
||||
Lokales Arbeiten ist Teil der Schulung und weitere Labs bauen darauf auf.
|
||||
|
||||
Container Technologie ist ein guter Weg, um reproduzierbare Ergebnisse
|
||||
zu erhalten und komfortabel zu arbeiten.
|
||||
|
||||
Methoden:
|
||||
|
||||
- Lokale Installation
|
||||
- Docker Container
|
||||
|
||||
|
||||
|
||||
= Lokale Installation
|
||||
|
||||
== Windows
|
||||
|
||||
Gehen Sie auf die offizielle Seite von Eclipse Mosquitto und
|
||||
laden Sie den neusten 64 Bit Installer herunter.
|
||||
|
||||
https://mosquitto.org/files/binary/win64/
|
||||
|
||||
Führen Sie die Installationsdatei aus und befolgen Sie den Anweisungen.
|
||||
|
||||
Merken Sie sich das Installationsverzeichnis.
|
||||
|
||||
Standardmäßig wird Mosquitto unter 'C:\Program Files\Mosquitto'
|
||||
installiert.
|
||||
|
||||
Starten Sie eine Kommandozeile und navigieren Sie in das
|
||||
Installationsverzeichnis von Mosquitto.
|
||||
|
||||
Installation abgeschlossen, weiter bei "Starten"
|
||||
|
||||
|
||||
== Linux
|
||||
|
||||
Mosquitto wird nicht mehr als Binärpaket für Linux auf mosquitto.org angeboten.
|
||||
Die Installationsmethode ist daher abhängig von der verwendeten Linux Distribution.
|
||||
Das Beispiel nutzt Debian/Ubuntu/Armbian.
|
||||
|
||||
Zum Testen kann auch das in Docker ausprobiert werden
|
||||
(wobei dann auch direkt ein Mosquiotto Container genutzt werden kann):
|
||||
Dazu:
|
||||
1) Ubuntu Container als "virtuelle Maschine" starten 2) darin die Kommandos ausführen
|
||||
$ docker run --privileged --cgroupns=host --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:rw geerlingguy/docker-ubuntu2404-ansible
|
||||
$ docker exec -it $(docker ps -q --latest) /bin/bash
|
||||
|
||||
|
||||
Fügen Sie das Mosquitto PPA APT Repository hinzu:
|
||||
|
||||
$ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
|
||||
$ sudo apt-get update
|
||||
|
||||
Installieren Sie nun Mosquitto:
|
||||
|
||||
$ sudo apt-get install mosquitto
|
||||
|
||||
Der Broker sollte automatisch als Service gestartet werden.
|
||||
|
||||
Um ihn manuell zu starten, und die Kommandozeile zu sehen, stoppen
|
||||
Sie den Mosquitto Broker und starten Sie ihn erneut.
|
||||
|
||||
$ sudo systemctl stop mosquitto
|
||||
# ggf. pruefen ("Active: inactive") mittels "sudo systemctl status mosquitto"
|
||||
|
||||
Installation abgeschlossen, weiter bei "Starten"
|
||||
|
||||
|
||||
== MacOS
|
||||
|
||||
Installieren Sie den Mosquitto Broker über Brew.
|
||||
|
||||
$ brew install mosquitto
|
||||
|
||||
Installation abgeschlossen, weiter bei "Starten"
|
||||
|
||||
|
||||
|
||||
|
||||
= Starten des Mosquitto Brokers
|
||||
|
||||
Führen Sie den Befehl 'mosquitto -h' aus, um unterstützte Befehle von
|
||||
Mosquitto zu sehen.
|
||||
|
||||
Führen Sie den Befehl 'mosquitto -v' aus um den Broker zu starten und
|
||||
um die Aktivität des Brokers in der Kommandozeile mitzuverfolgen können.
|
||||
|
||||
|
||||
|
||||
|
||||
= Verwendung Docker
|
||||
|
||||
Da das offizielle Container Image von Mosquitto keine anonymen Verbindungen erlaubt,
|
||||
wird eine Konfigurationdatei benötigt, die dann in den Docker Container eingebunden wird.
|
||||
|
||||
Erstellen Sie dazu eine Datei mit dem Namen 'mosquitto.conf' und folgendem Inhalt:
|
||||
|
||||
allow_anonymous true
|
||||
listener 1883
|
||||
|
||||
|
||||
Um den Mosquitto Broker als Docker Container zu starten führen Sie
|
||||
folgenden Befehl im selben Verzeichnis, wie die Konfigurationsdatei aus:
|
||||
|
||||
$ docker run --rm -p 1883:1883 -v $PWD/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
|
||||
|
||||
Diesel Befehl startet einen Container mit den Mosquitto Broker, verbindet
|
||||
den Host Port 1883 mit den Port 1883 des Containers und bindet die
|
||||
Konfigurationdatei an passender Stelle ein.
|
||||
|
||||
|
||||
= Referenzen
|
||||
|
||||
Download Page von Mosquitto https://mosquitto.org/download/
|
||||
|
||||
Docker Desktop Installation https://docs.docker.com/desktop/
|
||||
|
||||
Docker Standalone Installation https://docs.docker.com/engine/install/
|
||||
|
||||
Docker Container Runtime für MacOS https://github.com/abiosoft/colima
|
||||
|
||||
Mosquitto Docker Container https://hub.docker.com/_/eclipse-mosquitto
|
||||
2
01-basics/lab01/mosquitto.conf
Normal file
2
01-basics/lab01/mosquitto.conf
Normal file
@ -0,0 +1,2 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
7
01-basics/lab02/docker-compose.yml
Normal file
7
01-basics/lab02/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
30
01-basics/lab02/lab.txt
Normal file
30
01-basics/lab02/lab.txt
Normal file
@ -0,0 +1,30 @@
|
||||
= Docker Compose
|
||||
|
||||
Mittels docker-compose lassen sich auch komplexere Setups auf einfache Weise
|
||||
reproduzierbar konfigurieren.
|
||||
|
||||
Erstellen Sie dazu eine 'docker-compose.yml' Datei mit folgendem Inhalt.
|
||||
|
||||
`
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
`
|
||||
|
||||
Um den Container zu starten, verwenden Sie nun im selben Verzeichnis, wie
|
||||
die Konfigurationsdatei 'docker-compose.yml', folgenden Befehl:
|
||||
|
||||
$ docker compose up
|
||||
|
||||
Stoppen erfolgt durch CTRL-C oder docker-compose down
|
||||
|
||||
$ docker compose down
|
||||
|
||||
|
||||
= Referenzen
|
||||
|
||||
https://docs.docker.com/compose/
|
||||
2
01-basics/lab02/mosquitto.conf
Normal file
2
01-basics/lab02/mosquitto.conf
Normal file
@ -0,0 +1,2 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
7
01-basics/lab03/docker-compose.yml
Normal file
7
01-basics/lab03/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
24
01-basics/lab03/lab.txt
Normal file
24
01-basics/lab03/lab.txt
Normal file
@ -0,0 +1,24 @@
|
||||
= Broker Zugriff mit cURL
|
||||
|
||||
Nutzen Sie cURL als einfachen Client, um sich mit Ihrem Broker
|
||||
zu verbinden.
|
||||
|
||||
Verwenden Sie folgende Parameter:
|
||||
|
||||
* URL mqtt://localhost/\$SYS/broker/uptime (Zu beachten: Das Dollarzeichen
|
||||
wird ggf. durch die Shell interpretiert. Enteder mit Backslash escapen
|
||||
oder die gesamte URL in einfache Anführungszeichen setzen.)
|
||||
* `--trace -` Detailausgabe der Verbindungsdaten auf stdout
|
||||
* `--output -` Ausgabe auch von Binärdaten auf stdout erlauben
|
||||
|
||||
|
||||
|
||||
Umsetzung:
|
||||
|
||||
$ curl --output - --trace - mqtt://localhost/\$SYS/broker/uptime
|
||||
|
||||
|
||||
|
||||
= Referenzen
|
||||
|
||||
https://curl.se/docs/mqtt.html
|
||||
2
01-basics/lab03/mosquitto.conf
Normal file
2
01-basics/lab03/mosquitto.conf
Normal file
@ -0,0 +1,2 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
7
01-basics/lab04/docker-compose.yml
Normal file
7
01-basics/lab04/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
32
01-basics/lab04/lab.txt
Normal file
32
01-basics/lab04/lab.txt
Normal file
@ -0,0 +1,32 @@
|
||||
= Abbonnieren von Topics
|
||||
|
||||
Nutzen Sie mosquitto_sub als Client, lokal installiert (siehe lab01) oder als Container.
|
||||
|
||||
Bei Verwendung von Docker kann der Aufruf so aussehen:
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub
|
||||
|
||||
bei lokaler Installation ist der Befehl lediglich
|
||||
|
||||
$ mosquitto_sub
|
||||
|
||||
Lassen Sie sich zunächst die Hilfe ausgeben:
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub --help
|
||||
|
||||
|
||||
Subscriben Sie auf das Topic `$SYS/broker/uptime` (Shell Escape beachten)
|
||||
Beenden mit CTRL-C
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub --topic '$SYS/broker/uptime'
|
||||
|
||||
Testen Sie auch die Debug-Ausgabe
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub --topic '$SYS/broker/uptime' --debug
|
||||
|
||||
|
||||
Können Sie mehrere Topics gleichzeitig abbonieren? Verwenden Sie '$SYS/broker/bytes/sent' .
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub --topic '$SYS/broker/uptime' --topic '$SYS/broker/bytes/sent'
|
||||
|
||||
2
01-basics/lab04/mosquitto.conf
Normal file
2
01-basics/lab04/mosquitto.conf
Normal file
@ -0,0 +1,2 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
7
01-basics/lab05/docker-compose.yml
Normal file
7
01-basics/lab05/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
36
01-basics/lab05/lab.txt
Normal file
36
01-basics/lab05/lab.txt
Normal file
@ -0,0 +1,36 @@
|
||||
= Anpassung Konfiguration Mosquitto Broker
|
||||
|
||||
Lassen Sie ein mosquitto_sub mit Debug-Ausgabe laufen, z.B.
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub \
|
||||
--debug --topic '$SYS/broker/uptime' --topic '$SYS/broker/bytes/sent'
|
||||
|
||||
|
||||
|
||||
Passen Sie die mosquitto.conf mit einem neuen Konfigrationswert an:
|
||||
|
||||
sys_interval 3
|
||||
|
||||
Stoppen (z.B. CTRL-C oder `docker compose stop`) und starten Sie Mosquitto mit
|
||||
der neuen Konfiguration.
|
||||
Beachten Sie die neuen CONNECT und SUBSCRIBE Pakete des Clients!
|
||||
|
||||
Passen Sie den Wert in der Konfigurationsdatei nochmals an.
|
||||
Senden Sie ein HUP Signal an den Mosquitto Prozess.
|
||||
(Sendet das Standard Unix Signal SIGHUP. Wird von vielen Diensten
|
||||
(mosquitto, nginx, sshd ...) als Aufforderung gesehen, Konfiguration
|
||||
neu zu laden ohne den Prozess zu beenden.)
|
||||
|
||||
$ docker compose exec mosquitto kill -HUP 1
|
||||
|
||||
Beachten Sie, dass es zu keiner Unterbrechung des Clients kommt.
|
||||
|
||||
|
||||
= Referenzen
|
||||
|
||||
Mosquitto Konfigurationdatei https://mosquitto.org/man/mosquitto-conf-5.html
|
||||
|
||||
Docker Compose Installation https://docs.docker.com/compose/install/
|
||||
|
||||
Docker Volumes https://docs.docker.com/engine/storage/volumes/
|
||||
4
01-basics/lab05/mosquitto.conf
Normal file
4
01-basics/lab05/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab06/docker-compose.yml
Normal file
7
01-basics/lab06/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
34
01-basics/lab06/lab.txt
Normal file
34
01-basics/lab06/lab.txt
Normal file
@ -0,0 +1,34 @@
|
||||
= Publish
|
||||
|
||||
Nutzen Sie mosquitto_pub als Client und lassen sich zunächst die Hilfe ausgeben.
|
||||
|
||||
Sie können mosquitto_pub mit Docker ausführen:
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub --help
|
||||
|
||||
Publizieren Sie auf das Topic `training`.
|
||||
Verwenden Sie anschließend `mosquitto_sub` mit dem Topic, erhalten Sie die Nachricht?
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub --topic training --message "hello trion"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub --topic 'training' --debug
|
||||
|
||||
|
||||
Starten Sie zuerst die Subscription und publizieren Sie danach in einem separaten Terminalfenster.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub --topic 'training' --debug
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub --topic training --message "hello trion"
|
||||
|
||||
|
||||
Nutzen Sie mehrere Subscriber parallel, z.B. auch cURL
|
||||
|
||||
$ curl --output - --trace - mqtt://localhost/training
|
||||
|
||||
|
||||
|
||||
= Referenzen
|
||||
|
||||
mosquitto_sub https://mosquitto.org/man/mosquitto_sub-1.html
|
||||
|
||||
mosquitto_pub https://mosquitto.org/man/mosquitto_pub-1.html
|
||||
4
01-basics/lab06/mosquitto.conf
Normal file
4
01-basics/lab06/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab07/docker-compose.yml
Normal file
7
01-basics/lab07/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
31
01-basics/lab07/lab.txt
Normal file
31
01-basics/lab07/lab.txt
Normal file
@ -0,0 +1,31 @@
|
||||
= Single Level Wildcard
|
||||
|
||||
|
||||
Abbonieren Sie die Topics `training/+/student` und `schulung/+/+`
|
||||
|
||||
|
||||
Publizieren Sie Nachrichten nach
|
||||
- training/mqtt/student
|
||||
- schulung/mqtt/teilnehmer
|
||||
- training/all
|
||||
|
||||
Funktioniert alles, wie erwartet?
|
||||
|
||||
|
||||
Subscribe mit Wildcard
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub \
|
||||
--topic training/+/student --topic schulung/+/+ \
|
||||
--debug
|
||||
|
||||
|
||||
Publish
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub \
|
||||
--topic training/mqtt/student --message "hello: training/mqtt/student"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub \
|
||||
--topic schulung/mqtt/teilnehmer --message "hello: schulung/mqtt/teilnehmer"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub \
|
||||
--topic training/all --message "hello: training/all"
|
||||
4
01-basics/lab07/mosquitto.conf
Normal file
4
01-basics/lab07/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab08/docker-compose.yml
Normal file
7
01-basics/lab08/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
47
01-basics/lab08/lab.txt
Normal file
47
01-basics/lab08/lab.txt
Normal file
@ -0,0 +1,47 @@
|
||||
= Multi Level Wildcard
|
||||
|
||||
Abbonieren Sie einmal alles.
|
||||
|
||||
|
||||
Abbonieren Sie alles, was zu `training` oder `schulung` gehört.
|
||||
|
||||
Senden Sie Nachrichten an
|
||||
- training/mqtt/student
|
||||
- schulung/mqtt/teilnehmer
|
||||
- all
|
||||
|
||||
Funktioniert alles, wie erwartet?
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub \
|
||||
--topic '#' \
|
||||
--debug
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub \
|
||||
--topic 'training/#' --topic 'schulung/#' \
|
||||
--debug
|
||||
|
||||
|
||||
Versand der Testnachrichten:
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub \
|
||||
--topic training/mqtt/student --message "hello: training/mqtt/student"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub \
|
||||
--topic schulung/mqtt/teilnehmer --message "hello: schulung/mqtt/teilnehmer"
|
||||
|
||||
// FIX: nur topic 'all' um zu zeigen das dieses nur bei dem ersten sub erhalten wird
|
||||
aber nicht bei 'training/#' und 'schulung/#'
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub \
|
||||
--topic all --message "hello: all"
|
||||
|
||||
|
||||
|
||||
Erhalten Sie auch System-Nachrichten?
|
||||
|
||||
Abbonieren Sie explizit alle `$SYS` Topics.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_sub \
|
||||
--topic '$SYS/#' \
|
||||
--debug
|
||||
|
||||
4
01-basics/lab08/mosquitto.conf
Normal file
4
01-basics/lab08/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab09/docker-compose.yml
Normal file
7
01-basics/lab09/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
46
01-basics/lab09/lab.txt
Normal file
46
01-basics/lab09/lab.txt
Normal file
@ -0,0 +1,46 @@
|
||||
= MQTT Topic Visualisierung mit dem MQTT Explorer
|
||||
|
||||
Installieren Sie den MQTTExplorer und interagieren Sie mit Ihrem Mosquitto Broker.
|
||||
|
||||
|
||||
MQTTExplorer installieren:
|
||||
|
||||
Gehen Sie auf die offizielle Webseite des MQTTExplorers ( https://mqtt-explorer.com/ )
|
||||
|
||||
Laden Sie die passende Version für Ihr Betriebssystem herunter und installiere Sie diese.
|
||||
|
||||
Für Debian/Ubuntu kann das .deb-Paket verwendet werden.
|
||||
Installation:
|
||||
|
||||
$ wget https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.4.0-beta.6/MQTT-Explorer_0.4.0-beta.6_amd64.deb
|
||||
$ sudo dpkg -i MQTT-Explorer_0.4.0-beta.6_amd64.deb
|
||||
|
||||
Hinweis zu macOS: Bei macOS sollte die AppStore Version des MQTT Explorers genutzt werden.
|
||||
Dies ist eine etwas veraltete Version. Die neuste Version wird von macOS blockiert.
|
||||
|
||||
|
||||
Starten Sie den MQTTExplorer.
|
||||
|
||||
$ mqtt-explorer
|
||||
|
||||
|
||||
|
||||
Broker Verbindung mit dem MQTTExplorer:
|
||||
|
||||
Klicken Sie auf das '+' Symbol um eine neue Verbindung hinzuzufügen.
|
||||
|
||||
Geben Sie der Verbindung einen Namen (bspw. Mosquitto) und tragen Sie als Host 'localhost' ein.
|
||||
|
||||
Klicken Sie auf Speichern und dann auf Verbinden.
|
||||
|
||||
Nun können Sie das Interface des MQTTExplorers nutzen um Nachrichten zu senden und alle Nachrichten zu sehen,
|
||||
die der Broker empfängt.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
= Quellen
|
||||
|
||||
MQTTExplorer https://mqtt-explorer.com
|
||||
4
01-basics/lab09/mosquitto.conf
Normal file
4
01-basics/lab09/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab10/docker-compose.yml
Normal file
7
01-basics/lab10/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
78
01-basics/lab10/lab.txt
Normal file
78
01-basics/lab10/lab.txt
Normal file
@ -0,0 +1,78 @@
|
||||
= Session
|
||||
|
||||
Verwenden Sie `mosquitto_sub`, eine feste Client-ID (`--id`), QoS 1, deaktiviertes Clean-Session (`-c`) und Topic `demo` +
|
||||
`mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug`
|
||||
|
||||
Beenden Sie mittels `CTRL-C`, senden dann mehrere Nachrichten mit QoS 1 an das Topic `demo` und starten `mosquitto_sub` erneut
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug
|
||||
|
||||
CTRL-C
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 1"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 2"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 3"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug
|
||||
|
||||
|
||||
Wiederholen Sie den Vorgang, verwenden Sie statt `CTRL-C` zum Beenden `sudo killall -KILL mosquitto_sub`.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug
|
||||
|
||||
$ sudo killall -KILL mosquitto_sub
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 1"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 2"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 3"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug
|
||||
|
||||
|
||||
|
||||
|
||||
Testen Sie, ob der Versand mit QoS 0 sich genauso verhält
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug
|
||||
|
||||
CTRL-C
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 0 --message "Demo message 1"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 0 --message "Demo message 2"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug
|
||||
|
||||
|
||||
|
||||
Was ist, falls der Subscriber QoS 0 verwendet und der Publisher QoS 1?
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 0 --disable-clean-session --debug
|
||||
|
||||
CTRL-C
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 1"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic "demo" --qos 1 --message "Demo message 2"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --topic demo --id demo --qos 1 --disable-clean-session --debug
|
||||
|
||||
|
||||
2
01-basics/lab10/mosquitto.conf
Normal file
2
01-basics/lab10/mosquitto.conf
Normal file
@ -0,0 +1,2 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
7
01-basics/lab11/docker-compose.yml
Normal file
7
01-basics/lab11/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
32
01-basics/lab11/lab.txt
Normal file
32
01-basics/lab11/lab.txt
Normal file
@ -0,0 +1,32 @@
|
||||
= Wireshark
|
||||
|
||||
|
||||
Installieren Sie Wireshark und/oder tshark.
|
||||
|
||||
$ sudo apt update; sudo apt -y install tshark wireshark
|
||||
|
||||
|
||||
Verwenden Sie Wireshark (oder tshark) mit Port 1883 und MQTT Protokollanalyse
|
||||
|
||||
Wireshark: Interface "loopback / lo ", Apply a display filter: "tcp.port == 1883"
|
||||
|
||||
tshark:
|
||||
|
||||
$ tshark -s 1500 -i lo -n -x -O mqtt port 1883
|
||||
|
||||
|
||||
|
||||
Senden Sie die Nachricht 'hello trion' an das Topic `training`
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto mosquitto_pub \
|
||||
--topic training --message "hello trion"
|
||||
|
||||
|
||||
Analysieren Sie die gesendeten und empfangenen Daten
|
||||
|
||||
|
||||
|
||||
|
||||
= Quellen
|
||||
|
||||
Wireshark: https://www.wireshark.org/
|
||||
4
01-basics/lab11/mosquitto.conf
Normal file
4
01-basics/lab11/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab12/docker-compose.yml
Normal file
7
01-basics/lab12/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
55
01-basics/lab12/lab.txt
Normal file
55
01-basics/lab12/lab.txt
Normal file
@ -0,0 +1,55 @@
|
||||
= QoS 0 TCP Absicherung
|
||||
|
||||
Ziel ist zu sehen, wie TCP bei Verbindungsproblemen die Applikationsschicht absichert.
|
||||
|
||||
Dazu wird für den TCP Port 1883 ein Paketverlust von 50% konfiguriert und Anschließend
|
||||
Nachrichten versendet und konsumiert.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug --topic demo/qos0 -q 0
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub --topic demo/qos0 -q 0 --message "before tcp loss"
|
||||
|
||||
|
||||
In separatem Terminal wird nun das Netzwerk so konfiguriert, dass es
|
||||
hohen IP Paketverlust (50%) gibt:
|
||||
|
||||
(falls Docker genutzt wird)
|
||||
$ docker run --rm -it --net host --cap-add NET_ADMIN alpine:3
|
||||
# apk -U add iptables iproute2 iproute2-ss
|
||||
|
||||
(ohne Docker, Debian/Ubuntu)
|
||||
$ sudo apt install -y iptables iproute2
|
||||
$ sudo bash
|
||||
|
||||
|
||||
# iptables -t mangle -A POSTROUTING -o lo -p tcp --sport 1883 -j MARK --set-mark 1
|
||||
# iptables -t mangle -A PREROUTING -i lo -p tcp --dport 1883 -j MARK --set-mark 1
|
||||
|
||||
# tc qdisc add dev lo root handle 1: prio
|
||||
# tc filter add dev lo parent 1:0 protocol ip handle 1 fw flowid 1:1
|
||||
# tc qdisc add dev lo parent 1:1 handle 10: netem loss 50%
|
||||
|
||||
|
||||
Im ersten Terminal werden nun mehrere Nachrichten versandt:
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos0 -q 0 -m "this will be save #1"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos0 -q 0 -m "this will be save #2"
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos0 -q 0 -m "this will be save #3"
|
||||
|
||||
|
||||
|
||||
Anschließendes Aufräumen:
|
||||
|
||||
# iptables -t mangle -F
|
||||
# tc qdisc del dev lo root
|
||||
|
||||
|
||||
|
||||
= Quellen
|
||||
|
||||
Wireshark: https://www.wireshark.org/
|
||||
4
01-basics/lab12/mosquitto.conf
Normal file
4
01-basics/lab12/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab13/docker-compose.yml
Normal file
7
01-basics/lab13/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
55
01-basics/lab13/lab.txt
Normal file
55
01-basics/lab13/lab.txt
Normal file
@ -0,0 +1,55 @@
|
||||
= QoS 0 Verlust von Nachrichten
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug --topic demo/qos0 -q 0
|
||||
|
||||
|
||||
In separatem Terminal wird nun das Netzwerk so konfiguriert, dass es
|
||||
hohe Latenzen (3 Sekunden) gibt, dies macht es leichter, zum richtigen Zeitpunkt
|
||||
die Verbindung zu unterbrechen:
|
||||
|
||||
(falls Docker genutzt wird)
|
||||
$ docker run --rm -it --net host --cap-add NET_ADMIN alpine:3
|
||||
# apk -U add iptables iproute2 iproute2-ss
|
||||
|
||||
(ohne Docker, Debian/Ubuntu)
|
||||
$ sudo apt install -y iptables iproute2
|
||||
$ sudo bash
|
||||
|
||||
|
||||
# iptables -t mangle -A POSTROUTING -o lo -p tcp --sport 1883 -j MARK --set-mark 1
|
||||
# iptables -t mangle -A PREROUTING -i lo -p tcp --dport 1883 -j MARK --set-mark 1
|
||||
|
||||
# tc qdisc add dev lo root handle 1: prio
|
||||
# tc filter add dev lo parent 1:0 protocol ip handle 1 fw flowid 1:1
|
||||
# tc qdisc add dev lo parent 1:1 handle 10: netem delay 3s
|
||||
|
||||
|
||||
Im ersten Terminal werden nun mehrere Nachrichten versandt:
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos0 -q 0 -m "this will be save #1"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos0 -q 0 -m "this will be lost #2"
|
||||
|
||||
(Nach ca. 6 Sekunden werden die TCP Verbindungen im zweiten Terminal unterbrochen)
|
||||
# ss -t -K sport = :1883
|
||||
|
||||
(Neuer Versand funktioniert)
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos0 -q 0 -m "this will be save #3"
|
||||
|
||||
|
||||
|
||||
Anschließendes Aufräumen:
|
||||
|
||||
# iptables -t mangle -F
|
||||
# tc qdisc del dev lo root
|
||||
|
||||
|
||||
|
||||
= Quellen
|
||||
|
||||
Wireshark: https://www.wireshark.org/
|
||||
4
01-basics/lab13/mosquitto.conf
Normal file
4
01-basics/lab13/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab14/docker-compose.yml
Normal file
7
01-basics/lab14/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
73
01-basics/lab14/lab.txt
Normal file
73
01-basics/lab14/lab.txt
Normal file
@ -0,0 +1,73 @@
|
||||
= QoS 1 Nachlieferung
|
||||
|
||||
Subscribe mit expliziter Client ID und "clean session" auf "false".
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug --topic demo/qos1 --qos 1 --disable-clean-session --id demo
|
||||
|
||||
|
||||
In separatem Terminal wird nun das Netzwerk so konfiguriert, dass es
|
||||
hohe Latenzen (3 Sekunden) gibt, dies macht es leichter, zum richtigen Zeitpunkt
|
||||
die Verbindung zu unterbrechen:
|
||||
|
||||
|
||||
(falls Docker genutzt wird)
|
||||
$ docker run --rm -it --net host --cap-add NET_ADMIN alpine:3
|
||||
# apk -U add iptables iproute2 iproute2-ss
|
||||
|
||||
(ohne Docker, Debian/Ubuntu)
|
||||
$ sudo apt install -y iptables iproute2
|
||||
$ sudo bash
|
||||
|
||||
|
||||
# iptables -t mangle -A POSTROUTING -o lo -p tcp --sport 1883 -j MARK --set-mark 1
|
||||
# iptables -t mangle -A PREROUTING -i lo -p tcp --dport 1883 -j MARK --set-mark 1
|
||||
|
||||
# tc qdisc add dev lo root handle 1: prio
|
||||
# tc filter add dev lo parent 1:0 protocol ip handle 1 fw flowid 1:1
|
||||
# tc qdisc add dev lo parent 1:1 handle 10: netem delay 3s
|
||||
|
||||
|
||||
|
||||
Ermittlung des Ports des Subscribers:
|
||||
|
||||
# ss -t sport = :1883
|
||||
|
||||
|
||||
|
||||
Im ersten Terminal werden nun mehrere Nachrichten versandt:
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos1 -q 1 -m "This is delivered. #1"
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_pub -t demo/qos1 -q 1 -m " #### This could be delivered later. #2"
|
||||
|
||||
Nach ca. 3 Sekunden werden die TCP Verbindungen des Subscribers im zweiten Terminal unterbrochen)
|
||||
# ss -t -K sport = :60804
|
||||
|
||||
Optional: Im ersten Terminal wird mittels mehrfachem CTRL-C der Subscriber beendet.
|
||||
Anschließend erfolgt neuer Start.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug -t demo/qos1 --qos 1 --disable-clean-session --id demo
|
||||
|
||||
|
||||
Testen Sie auch, was passiert, wenn beim Neustart ein völlig anderes Topic angegeben wird -
|
||||
wird die nicht erhaltene Nachricht trotzdem ausgeliefert?
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug -t demo/othertopic --qos 1 --disable-clean-session --id demo
|
||||
|
||||
|
||||
|
||||
Anschließendes Aufräumen:
|
||||
|
||||
# iptables -t mangle -F
|
||||
# tc qdisc del dev lo root
|
||||
|
||||
|
||||
|
||||
= Quellen
|
||||
|
||||
Wireshark: https://www.wireshark.org/
|
||||
4
01-basics/lab14/mosquitto.conf
Normal file
4
01-basics/lab14/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab15/docker-compose.yml
Normal file
7
01-basics/lab15/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
37
01-basics/lab15/lab.txt
Normal file
37
01-basics/lab15/lab.txt
Normal file
@ -0,0 +1,37 @@
|
||||
= Retained Message
|
||||
|
||||
|
||||
Publizieren Sie alle 20 Sekunden eine Nachricht mit aktueller Zeit, einmal mit
|
||||
retained Flag, einmal ohne in jeweils separate Topics:
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
/bin/sh -c 'while true; do mosquitto_pub
|
||||
-t demo/retained --qos 1 --retain -m "$(date)"; sleep 20; done'
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
/bin/sh -c 'while true; do mosquitto_pub
|
||||
-t demo/not-retained --qos 1 -m "$(date)"; sleep 20; done'
|
||||
|
||||
|
||||
Lesen Sie die Topics und beobachten das Verhalten.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug --topic demo/retained --qos 1 --disable-clean-session --id demo
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug --topic demo/not-retained --qos 1 --disable-clean-session --id demo
|
||||
|
||||
|
||||
Beenden Sie die Publisher und starten erneut Subscriber und vergleichen das
|
||||
Verhalten der beiden Topics.
|
||||
|
||||
|
||||
Testen Sie bei dem Subscriber verschiedene QoS Level, Client-ID und Clean-Session Kombinationen.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug --topic demo/retained --qos 0 --disable-clean-session --id demo
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug --topic demo/retained --qos 1
|
||||
|
||||
4
01-basics/lab15/mosquitto.conf
Normal file
4
01-basics/lab15/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
7
01-basics/lab16/docker-compose.yml
Normal file
7
01-basics/lab16/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
37
01-basics/lab16/lab.txt
Normal file
37
01-basics/lab16/lab.txt
Normal file
@ -0,0 +1,37 @@
|
||||
= Last Will and Testament
|
||||
|
||||
Nutzen Sie eine Last Will Nachricht mit dem 'mosquitto_pub' Befehl,
|
||||
um auf dem Topic "clients/demo/status" eine Status Nachricht zu bekommen, sobald der
|
||||
Publisher Client die Verbindung abbricht.
|
||||
(Im Lab Ordner ist eine beispielhafte Umsetzung mit will-docker-compose.yaml als Referenz)
|
||||
|
||||
Subscriben Sie das Will Topic "clients/+/status"
|
||||
|
||||
Beenden Sie den Publisher einmal mit CTRL-C und killen Sie ihn (`kill -SIGKILL`) oder den
|
||||
zugehörigen TCP Socket (`ss sport =: 1883` und `ss -K sport =:9999`)
|
||||
|
||||
|
||||
|
||||
Subscriben Sie das Topic "clients/+/status".
|
||||
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --debug -t clients/+/status
|
||||
|
||||
|
||||
Verwenden Sie einen Client mit Last Will Nachricht.
|
||||
|
||||
$ docker run --rm -it --net host eclipse-mosquitto \
|
||||
mosquitto_sub --will-topic clients/room1/status --will-payload offline --will-qos 1 --topic demo
|
||||
|
||||
Nutzen Sie folgenden Befehl, um die Sockets der Clients zu finden:
|
||||
|
||||
$ docker run --rm -it --net host --cap-add NET_ADMIN alpine:3
|
||||
# apk -U add iptables iproute2 iproute2-ss
|
||||
# ss -t sport = :1883
|
||||
|
||||
Beenden Sie die TCP Verbindungen mit dem Befehl (Port anpassen):
|
||||
|
||||
# ss -t -K sport = :9999
|
||||
|
||||
|
||||
4
01-basics/lab16/mosquitto.conf
Normal file
4
01-basics/lab16/mosquitto.conf
Normal file
@ -0,0 +1,4 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
# sys_interval 3
|
||||
28
01-basics/lab16/will-docker-compose.yml
Normal file
28
01-basics/lab16/will-docker-compose.yml
Normal file
@ -0,0 +1,28 @@
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
|
||||
subscriber:
|
||||
image: eclipse-mosquitto
|
||||
network_mode: host
|
||||
depends_on:
|
||||
- mosquitto
|
||||
command: >
|
||||
sh -c "
|
||||
mosquitto_sub -t clients/+/status
|
||||
"
|
||||
|
||||
lwt-publisher:
|
||||
image: eclipse-mosquitto
|
||||
network_mode: host
|
||||
depends_on:
|
||||
- mosquitto
|
||||
- subscriber
|
||||
command: >
|
||||
sh -c "
|
||||
mosquitto_sub -t sensors/room1/temperature --will-topic clients/room1/status --will-payload offline --will-qos 1
|
||||
"
|
||||
Reference in New Issue
Block a user