it:iot:mosquitto

Toto je starší verze dokumentu!


Mosquitto

V tutoriálu je srozumitelně popsané, jak MQTT funguje.

Zapnutí autentizace

Vycházím z návodu Configuring the Mosquitto MQTT Docker container for use with Home Assistant, který popisuje zapnutí autentizace pro Mosquitto. Další informace jsem pak čerpal z tohoto článku: Deploying Mosquitto MQTT broker on Linux using Docker

V konfiguračním souboru mosquitto.conf nastavím/změním toto:

password_file /mosquitto/pwfile/pwfile
allow_anonymous false

Pak se připojím do kontejneru s mosquitto a vytvořím uživatele s heslem:

docker exec -it mosqutto sh
mosquitto_passwd -c /mosquitto/pwfile/pwfile majordomus

Nakonec retartovat kontejner s Mosquitto.

Příkaz pro čtení s autentizací:

$ mosquitto_sub -u henry --pw 'passw0rd' -h localhost -p 1883 -v -t test/message

Příkaz pro publikaci s autentizací:

$ mosquitto_pub -u henry -P 'passw0rd' -h localhost -p 1883 -t test/message -m 'Hello World!'

Do konfiguračního souboru lze dle zdroje přidat tyto řádky:

# Types of messages to log. Use multiple log_type lines for logging
# multiple types of messages.
# Possible types are: debug, error, warning, notice, information, 
# none, subscribe, unsubscribe, websockets, all.
# Note that debug type messages are for decoding the incoming/outgoing
# network packets. They are not logged in "topics".
log_type error
log_type warning
log_type notice
log_type information
  • it/iot/mosquitto.1672846457.txt.gz
  • Poslední úprava: 2023/01/04 15:34
  • autor: Petr Nosek