Skip to main content

Overview

This template provides a production‑ready Eclipse Mosquitto instance as a Monk runnable. You can:
  • Run it directly to get a managed MQTT broker with sensible defaults
  • Inherit it in your own runnable to seamlessly add MQTT messaging to your IoT infrastructure
It exposes MQTT on port 1883, WebSocket on port 9001, persists data to a host volume, and supports full MQTT v3.1, v3.1.1, and v5.0 protocols. Eclipse Mosquitto is an open-source message broker that is lightweight and suitable for use on all devices from low-power single board computers to full servers.

What this template manages

  • Mosquitto MQTT broker container (eclipse-mosquitto image, configurable tag)
  • Network service on port 1883 (MQTT)
  • Network service on port 9001 (WebSocket)
  • Persistent volumes for data storage
  • Auto-generated configuration file with customizable settings

Quick start (run directly)

  1. Load templates
  1. Run Mosquitto with defaults
  1. Customize configuration (recommended via inheritance)
Running directly uses the defaults defined in this template’s variables. To customize settings, you can:
  • Preferred: inherit and override variables as shown below.
  • Alternative: fork/clone and edit the variables in mosquitto.yml, then monk load MANIFEST and run.
Once started, connect MQTT clients to localhost:1883 (or the runnable hostname inside Monk networks) and WebSocket clients to localhost:9001.

Configuration

Key variables you can customize in this template:
Data is persisted under ${monk-volume-path}/mosquitto/data on the host. The configuration file is auto-generated from the template at /mosquitto/config/mosquitto.conf. Inherit the Mosquitto runnable in your IoT application and declare a connection. Example:
Then run your app group:

Ports and connectivity

  • Service: mqtt on TCP port 1883 (default)
  • Service: websocket on TCP port 9001 (default)
  • From other runnables in the same process group, use connection-hostname("\<connection-name>") to resolve the broker host.

Persistence and configuration

  • Data path: ${monk-volume-path}/mosquitto/data:/mosquitto/data
  • Configuration is auto-generated from template variables and mounted at /mosquitto/config/mosquitto.conf
  • Supports message persistence, retained messages, and persistent sessions

Features

  • MQTT v3.1, v3.1.1, and v5.0 support
  • QoS levels 0, 1, and 2
  • Retained messages
  • Last Will and Testament
  • WebSocket support for browser-based clients
  • Message persistence
  • Configurable connection limits
  • Flexible logging
  • Use with microservices for async communication
  • Combine with stream processing (Kafka Streams, Flink)
  • Integrate with monitoring (prometheus-grafana/)
  • Pair with Node-RED for IoT workflow automation

Troubleshooting

  • If you changed allow-anonymous to false, ensure you have configured authentication (password file or auth plugin) in a custom configuration.
  • Ensure the host volumes are writable by the container user.
  • For production use, consider setting allow-anonymous: false and configuring proper authentication.
  • Check logs: