emqx-docker icon indicating copy to clipboard operation
emqx-docker copied to clipboard

Howto remove retain flag?

Open RaymondMouthaan opened this issue 6 years ago • 1 comments

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.

  • [ x] FEATURE REQUEST

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

RaymondMouthaan avatar Feb 11 '19 20:02 RaymondMouthaan

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.

turtleDeng avatar Apr 24 '19 15:04 turtleDeng