Hello,
Is there a way to delete retained messages in the broker?
I tried deleting the stashed messages, but the retained messages aren’t deleted.
Thanks!
Hello,
Is there a way to delete retained messages in the broker?
I tried deleting the stashed messages, but the retained messages aren’t deleted.
Thanks!
Thank you for your answer, I don’t mean this messages.
When a client subscribes to a topic, if there are retained messages, the client receives the last retained message. I want to delete those retained messages so when the client subscribes to the topic doesn’t receive anything until something new is published.
Buff! Sorry for the confusion, certainly “unconfirmed” is not the same as “retained”.
To clear those retained messages you can use standard MQTT method which is to send a PUBLISH message with the topic to clear with retain flag enabled and zero payload. That will trigger:
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
[MQTT-3.3.1-10] A PUBLISH Packet with a RETAIN flag set to 1 and a payload containing zero bytes will be processed as normal by the Server and sent to Clients with a subscription matching the topic name. Additionally any existing retained message with the same topic name MUST be removed and any future subscribers for the topic will not receive a retained message
At the same time, we will pass an indication to programming to see if it is possible to implement a retained inspector to better track and clear retained messages in your MQTT HUB.