emqxarchive / emqx-docker

This repository is no longer maintained, please go to https://github.com/emqx/emqx-rel/tree/master/deploy/docker
Apache License 2.0
235 stars 162 forks source link

Howto remove retain flag? #103

Open RaymondMouthaan opened 5 years ago

RaymondMouthaan commented 5 years ago

Make sure you read and understand https://developer.emqx.io/docs/emq/v3/en/index.html. Use one of the two templates below and delete the rest.


FEATURE REQUEST

remove retain flag from specific topic

Justification

Not sure if it's a bug or a missing feature, but I can't seem to find a way to remove a retain flag from a topic.

Test scenario: 1) Publish a message1 to a topic with retain: true 2) Subscribe to topic -> retained message1 is received 3) Publish an empty message to the topic with retain: false 4) Subscribe to topic -> retained message1 is received <-- Here no message was expected

Also read this https://medium.com/@emqtt/mqtt-in-a-nutshell-2040b244aa4b, but unfortunately it doesn't explain how to remove the retain flag.

As per https://emqx-enterprise-docs-en.readthedocs.io/en/latest/mqtt.html ...

Client sends an empty message using the same topic of the retained message should clean retain, but I've tried this with node-red and mqttfx as clients, but it doesn't work.

Workarounds

Only way to remove the retain flag from a topic is to restart the EMQ docker container(s), but this is most probably working since I have persistence not working ...

Please advise.

Regards, Ray

turtleDeng commented 5 years ago

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.