Skip to content

Latest commit

 

History

History

mosquitto

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Mosquitto

Mosquitto is an MQTT pub/sub message broker.

You can use it in combination with node-red to create easy task automation pipelines.

You can use it in combination with minio to respond to S3 bucket events (lambda)

Background

Good blog posts:

Enable MQTT Traefik Entrypoint

You must enable the MQTT Traefik entrypoint (TCP port 8883) and reinstall Traefik:

make -C ../traefik reconfigure var=TRAEFIK_MQTT_ENTRYPOINT_ENABLED=true
make -C ../traefik install

Config

Run make config or copy .env-dist to .env_${DOCKER_CONTEXT}_default, and edit variables accordingly.

  • MOSQUITTO_TRAEFIK_HOST the external domain name to forward from traefik.

Before starting mosquitto, create the user accounts you need:

make admin

The admin password will be printed to the terminal.

You can add additional users and print their passwords:

make user

List all the user accounts:

make list-users

Run

Start mosquitto with make install or docker-compose up -d

Test it

You must install the mosquitto client package with the same version (MOSQUITTO_VERSION in your .env file), so it is easiest to run a container for testing:

## Create a shell with mosquitto client (same version) installed:
make client

Subscribe to a topic:

PASSWORD=your_admin_password
mosquitto_sub -h mqtt.example.com -p 8883 -u admin -P ${PASSWORD} -t test

In another terminal, publish to the topic:

PASSWORD=your_admin_password
mosquitto_pub -h mqtt.example.com -p 8883 -u admin -P ${PASSWORD} -t test -m "test message"