EMQX Will Message Not Published on Disconnect
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about EMQX Will Message Not Published on Disconnect. We cover key concepts, practical examples, and best practices.
The Problem
Will message (Last Will and Testament) does not publish when the client disconnects unexpectedly.
Quick Fix
Wrong
mqttx pub -t status -m 'online' # No will message configured
When client disconnects, no "offline" notification sent.
Right
# Set will message on connection
mqttx sub -t test -h broker -p 1883 \
-u user -P pass \
--will-topic 'client/status' \
--will-message 'offline' \
--will-qos 1 \
--will-retain
# Publish online status
mqttx pub -t client/status -m 'online' -r
# Monitor will
mqttx sub -t client/status -v
"offline" appears on client/status topic after client disconnects unexpectedly.
Prevention
Will message is sent on: client disconnects without DISCONNECT packet, keep-alive timeout, or network failure. Configure wills at CONNECT time (cannot be changed after). Will QoS 1 or 2 ensures delivery. Retain flag allows clients to see last known status. Use TLS to prevent will spoofing.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro