0
votes

How can I prevent receiving the same message in MQTT what the same client has published?

Problem:

Client1 subscribes: site1/feeds/#

Client1 publishes: site1/feeds/one

Client1 receives: site1/feeds/one <- how can I prevent this on the local client?

Client2 publishes: site1/feeds/two

Client1 receives: site1/feeds/two <- this I want to keep

1
I don't think mqtt has any support for this - the spec for publish says that messages are sent to every subscribed client with no other distinction.Robert Horvick

1 Answers

1
votes

As Bubbafat said you can't prevent this at the protocol level and I'm not aware of any brokers that implement this as a feature.

Your only real option is to add a filter in the onMessage callback