Preventing MQTT Message Loops
A common misconfiguration in networks with MQTT gateways is the "MQTT loop" - packets sent over LoRa get forwarded to MQTT, which then re-injects them back into the LoRa network, causing each message to be transmitted multiple times and rapidly increasing channel utilization.
How MQTT Loops Happen
- Node A sends a message over LoRa
- Gateway node G receives the LoRa packet and publishes it to MQTT
- MQTT broker delivers the packet to Gateway G's downlink subscription
- Gateway G injects the packet back into the LoRa network
- Node A receives its own message again as if from the MQTT cloud
- This can loop indefinitely if not properly configured
Prevention: The ignore_mqtt Setting
A key anti-loop control is the lora.ignore_mqtt flag. When set to true, the device will ignore (and not re-broadcast) any messages it receives over LoRa that came via MQTT somewhere along the path toward the device. Note this only works when both your device and the MQTT node are running at least firmware version 2.2.19:
# Enable on ALL infrastructure nodes (routers, repeaters):
meshtastic --set lora.ignore_mqtt true
# Verify:
meshtastic --get lora.ignore_mqtt
Critical: Set this on every infrastructure/relaying node (ROUTER, ROUTER_LATE, and REPEATER roles). Leave it as false only on end-client nodes that may need to receive messages downlinked from MQTT.
Gateway Configuration Best Practices
# Configure the gateway node correctly:
# 1. Enable MQTT publishing (uplink):
meshtastic --ch-index 0 --ch-set uplink_enabled true
# 2. Enable MQTT subscribing (downlink) ONLY if needed:
# Only enable downlink if you want to receive messages sent to MQTT
# from the global mesh or other external systems.
# If you only want to publish (monitoring), keep downlink disabled:
meshtastic --ch-index 0 --ch-set downlink_enabled false
# 3. Enable ignore_mqtt on the gateway node itself:
meshtastic --set lora.ignore_mqtt true
Detecting a Loop in Progress
Signs that a loop is occurring:
- Channel utilization (CU) rapidly increasing after enabling MQTT
- Messages appearing in the chat multiple times
- The same packet ID appearing in MQTT subscription twice or more within a few seconds
- Nodes reporting high packet counts in stats
# Check channel utilization. There is no --get for this; it is a live
# telemetry metric, read it from --info or the app's node metrics.
# Aim to keep it under ~25% (the firmware begins delaying transmissions above that):
meshtastic --info
# Monitor for duplicate packet IDs via MQTT:
mosquitto_sub -t "msh/US/2/e/#" -v | grep -E "packet.id"
# Watch for repeating IDs within 30 seconds
No comments to display
No comments to display