Skip to content

lockfale/mqtt-example

Repository files navigation

Sample MQTT

Build

Pre-req (windows)

py3.12 poetry

pipx install poetry
poetry --version

https://scoop.sh/ https://pipx.pypa.io/stable/installation/

Running

Create lock file:

peotry lock

Install:

poetry install --no-root

Spin up the broker:

docker compose -f docker-compose.infrastructure.yaml up -d

Run subscriber:

poetry run .\subscriber.py

Publish a message:

poetry run .\publisher.py

Check the output in the subscriber:

[2025-05-18 17:58:38,591.591] [INFO] [subscriber.py:57]: Creating client: subscriber-local
[2025-05-18 17:58:38,591.591] [INFO] [subscriber.py:75]: Connecting to localhost:1883...
[2025-05-18 17:58:38,600.600] [INFO] [subscriber.py:15]: Connected with result code: Success
[2025-05-18 17:58:38,602.602] [INFO] [subscriber.py:43]: Subscribed with QoS: 1
[2025-05-18 17:58:41,802.802] [INFO] [subscriber.py:33]: some/cool/topic
[2025-05-18 17:58:41,802.802] [INFO] [subscriber.py:34]: b'{"hello": "world"}'

Maintenance

poetry run isort .
poetry run black .

About

sample mqtt python with emqx docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages