MQTT broker deployment for the Loading platform, powered by Eclipse Mosquitto.
Mosquitto is a lightweight open-source MQTT broker that enables messaging between IoT devices and consumers. This repository contains the Docker Compose deployment configuration for the Loading platform's MQTT broker.
| Port | Service | Protocol |
|---|---|---|
| 1883 | MQTT | Default unencrypted MQTT |
| 9001 | WebSocket | For web-based clients |
Configuration files are located in deploy/config/:
mosquitto.conf- Main broker configuration (ports, persistence, logging)pwfile- Password file for authentication (disabled by default)aclfile- Access control list for topic-based permissions (disabled by default)
listener 1883 # MQTT port
listener 9001 # WebSocket port
protocol websockets # Enable WebSocket support
persistence true # Enable message persistence
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
allow_anonymous true # Authentication disabled (enable for production)- Docker and Docker Compose
- External network
cmp-network
cd deploy
docker-compose up -ddocker-compose downdocker-compose logs -f mosquittoThe broker persists data to Docker volumes:
deploy/config/- Configuration filesdeploy/data/- Message persistence (mosquitto.db)deploy/log/- Broker logs
Authentication is disabled by default (allow_anonymous true). To enable:
-
Create a password file:
docker exec loading-mosquitto mosquitto_passwd -c /mosquitto/config/pwfile <username>
-
Uncomment the password line in
mosquitto.conf:password_file /mosquitto/config/pwfile
-
Optionally add an ACL file and uncomment:
acl_file /mosquitto/config/aclfile
-
Restart the broker:
docker-compose restart
┌─────────────────────────────────────────────────────────┐
│ Mosquitto │
│ (Docker Compose) │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ MQTT │ │ ACL │ │ Auth │ │ TLS │ │
│ │ Broker │ │ Manager │ │ Manager │ │ Support│ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
└─────────────────────┬───────────────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌─────────────┐ ┌───────────┐ ┌─────────┐
│ Node-RED │ │ IoT │ │ Other │
│ (Consumer) │ │ Devices │ │ Clients │
└─────────────┘ └───────────┘ └─────────┘
mosquitto_pub -h <host> -t "loading/sensors" -m "hello"
mosquitto_sub -h <host> -t "loading/sensors"Connect using any MQTT.js-compatible client with ws:// or wss:// protocol.
Eclipse Mosquitto is licensed under the Eclipse Public License. This deployment configuration is part of the Loading platform.