Clearing an MQTT Retained Message Is Not the Same as Publishing Zero
An asset has been retired, but a newly connected subscriber still receives its last value. Publishing the number zero is not a reliable way to remove that saved message: zero is data. In MQTT 3.1.1, retained-state removal has a specific zero-byte payload rule. Test it separately from deleting application history or resetting equipment.

Key takeaways |
A zero-byte publication with RETAIN set removes the retained message for that exact topic. A numeric zero, an empty JSON object and the text null are different payloads. Existing consumers still need explicit empty-message handling. |
1. Identify which state is actually stale
Capture the exact topic, payload bytes, publication time and subscription event in an isolated diagnostic environment. Establish whether the unexpected value arrives immediately after a new subscription or comes from application storage. The same number can appear through different paths, and changing the broker’s saved message will not necessarily clear a dashboard cache or historical database.
Start with the ProSight Software platform overview when discussing the required monitoring behaviour. Confirm the actual broker, client versions and supported integration route. This guide describes an MQTT protocol test; it does not advertise a retained-message management control in the platform.
Document who owns the source publication and who owns the displayed state. Removing a message while its publisher continues sending retained updates can produce a short-lived apparent fix. A controlled retirement needs an agreed source-side change as well as a clear acceptance outcome.
2. Distinguish absence from a measured zero
OASIS MQTT 3.1.1 section 3.3.1.3 specifies that a zero-byte payload with RETAIN set removes an existing retained message on the same topic. Matching existing subscribers receive the publication, while a future subscriber does not receive that removed retained message. The zero-byte message is not itself stored as a retained message.
A payload containing the character 0 still has a byte. So do the characters in null and {}. They cannot be treated as interchangeable with no payload. Check the diagnostic client’s documented input method; an apparently blank text field may be encoded differently from a genuine zero-length byte sequence.
Keep this operation separate from the physical measurement. A zero pressure reading may be meaningful process data. Never manufacture it to make a stale tile disappear, and never use retained-state maintenance as an instruction to reset a controller or clear a totaliser.

3. Run an isolated two-subscriber test
Use a test broker or an approved isolated namespace with harmless invented state. Publish a recognisable retained value to one exact topic, then establish a fresh test subscription and record the received value. Keep that subscriber connected so its behaviour can be compared with a second subscriber created later.
Perform the documented zero-byte retained publication to that test topic. Record what the already connected subscriber receives and how its application handles the empty payload. Then create the second fresh subscription. The acceptance check concerns the absence of the old retained message, not whether every application screen becomes blank.
If the source immediately republishes a retained value, the later subscriber may receive it legitimately. Keep the source quiescent during this specific fixture, then restore it under the test plan. Retain the publication and subscription timeline so the result is reproducible.
Diagnostic checks
Observation | Check next |
Fresh subscriber sees old value | Exact topic and later retained publications |
Existing consumer reports parse error | Its empty-payload handling |
Dashboard still shows a value | Application cache/history and freshness |
4. Define the application response
An empty payload should reach a controlled branch in the receiving integration. Decide whether it means no current state, an ignored maintenance message or another documented outcome. Do not let a JSON parser failure become an unexplained missing point, and do not silently substitute the last valid value with a fresh timestamp.
Retained-message removal does not erase historical records, revoke credentials or prove that an asset has stopped transmitting. Treat these as separate lifecycle tasks with appropriate authorisation. After a device replacement, verify the new asset identity and topic assignment before allowing its values into operational reports.
Save the tested topic, broker/client versions, expected empty-payload behaviour and source restart procedure in the handover. Repeat the fixture after changes to publication libraries or integration mappings.
Recommended equipment / related solutions
Use the ProSight Software platform overview to discuss monitoring and reporting scope. For a tailored interface and acceptance plan, review ProSight Custom. Confirm the broker, deployment and supported integration before implementation.
Related guide: MQTT Topic and Payload Design for Industrial IoT Dashboards. It covers the wider naming and payload context; this article addresses a specific protocol boundary.
Frequently asked question
Does publishing an empty payload without RETAIN clear the saved value?
No. Under MQTT 3.1.1, a publication with RETAIN clear does not remove or replace the retained message. Verify the actual flags as well as payload length.
Technical reference
OASIS MQTT 3.1.1 specification. Protocol scope in this guide is MQTT 3.1.1; project test and handover steps are engineering recommendations.
Need help with your application?
Discuss your ProSight Software integration requirement. Send the documented broker/client versions, a sanitised example and the required acceptance outcome.

.png)
Comments