LMQTT Broker is a compact MQTT 3.1.1 and MQTT 5.0 broker written in Lua for the Barracuda App Server runtime. It is designed for BAS-derived environments such as Mako Server, Xedge, and embedded BAS applications that need a complimentary, scriptable MQTT broker close to the application logic.
Use it when a BAS, Mako Server, or Xedge project should host its own broker instead of only connecting to an external MQTT service.
Start here when integrating the broker:
- LMQTT-Broker.md - broker API, options, callbacks, TLS setup, in-process client API, and feature scope.
www/.lua/mqttbroker.lua- the broker module; copy this file into your project.www/.preload- startup example that creates a SharkSSL TLS listener, enables a plain listener, and installs broker callbacks.design/test_mqtt_broker.py- Pythonpaho-mqtttest program.LMQTT-Broker.md- API reference and feature details.
The broker module is pre-integrated in the mako.zip included with the Mako Developer Edition. Use that package when you want the quickest host-side setup with Mako Server, Xedge, LSP-Claw, MQTT, and the LMQTT Broker already available.
The manual installation steps below are mainly for custom BAS, Mako Server, or Xedge projects where you want to copy the broker module yourself.
- MQTT 3.1.1 and MQTT 5.0 connection handling.
- QoS 0 publish/subscribe routing.
- MQTT over TLS with SharkSSL.
- Optional plain MQTT listener for development or controlled networks.
- Optional authentication callback.
- Optional publish policy callback.
- Optional wildcard-subscription blocking.
- In-process Lua client API for application-local publish/subscribe without loopback TCP.
The broker intentionally stays compact. It does not implement retained messages, persistent sessions, QoS 1/2 delivery state, shared subscriptions, topic aliases, or a general application-side publish API over the broker object. See LMQTT-Broker.md for details.
If you are not using the Mako Developer Edition, copy the broker module into your project:
www/.lua/mqttbroker.lua
When using a custom Mako Server setup, you may also integrate the module directly into mako.zip by adding it to the .lua directory inside the ZIP archive. Assuming mako.zip is in the current directory, run this from the www directory:
cd www
zip -r ../mako.zip .lua/mqttbroker.luaStart the example with Mako Server:
cd MQTT-Broker
mako -l::wwwThe default .preload starts:
- MQTT over TLS on
8883. - Plain MQTT on
1883. - A separate exact-subscription-only plain broker on
1884.
Mako's built-in default certificate is self-signed. Test clients must either trust it explicitly or disable certificate verification.
www/.preload calls mako.createloader(io) so Lua can load modules from www/.lua. It then creates a SharkSSL server object from Mako's internal certificate and starts the broker:
local mqttBroker,err=require("mqttbroker").create({
shark=shark,
plain=true,
auth=function(client,username,password)
if username == nil and password == nil then return true end
return username == "mqttuser" and password == "mqttpass"
end,
onpublish=function(client,topic,payload,retain)
if topic:sub(1,8) == "blocked/" then return false end
end,
onerror=function(client,etype,status)
trace("mqttbroker onerror",etype,status,client and client.clientId or "")
end
})With shark=shark, the broker defaults to TLS port 8883. With plain=true, it also opens a plain MQTT listener on 1883. Both listeners share the same broker state and subscription table.
Install the Python MQTT client if needed:
python -m pip install paho-mqttRun the full test suite from another terminal while Mako is running:
python design/test_mqtt_broker.py --tls --port 8883 --allThe full test covers:
- MQTT 3.1.1 and MQTT 5.0 connections.
- TLS connections that accept the self-signed Mako certificate.
- QoS 0 delivery.
+and#wildcard subscriptions.$topic wildcard exclusion.- Authentication accept/reject behavior.
- Publish policy allow/reject behavior.
- Cross-listener TLS-to-plain routing.
- QoS 1 rejection.
- Invalid wildcard rejection.
- MQTT 5 Topic Alias rejection.
This example can be packaged as an Xedge app by creating a ZIP from the app directory, so the app files are at the ZIP root. See Xedge App Deployment for the detailed deployment workflow.
cd www
zip -D -q -u -r -9 ../MQTT-Broker.zip .Upload the generated ZIP with the Xedge App Upload tool.
- If
mako -l::wwwfails with a bind error, another Mako instance may already be using ports1883,1884, or8883. - The default authentication callback allows anonymous clients for smoke testing. Supplied credentials must be
mqttuser/mqttpass. - Publications to topics beginning with
blocked/are dropped by the exampleonpublishcallback. - The broker on port
1884rejects any subscription containing+or#. - For production TLS, replace Mako's self-signed test certificate with a certificate chain trusted by your clients.
This code was generated using Codex. See the design documentation for additional details.