8

As a MQTT client I want to know how can I get subscriptions(TOPICS):

I use Paho library and java as a client, with connecting with setCleanSession(false) so the client subscriptions(TOPIC) keeps in MQTT broker after disconnecting, if the topic subscription didn't emits some data , I didn't know that subscription is alive.

so I want to get all topic subscriptions of my MQTT client and if some topic didn't emits data for 10 minutes , unsubscribe that topic.

  • The thing I'm actually trying is to react to unwanted messages to call unsubscribe. But my broker Mosquitto silently ignores my unsubscription. Think I want messages matching test/#, but I get a message from topic another/test. I could unsubscribe from "another/test" but may be the broker don't have a subscription to that, maybe it keeps a subscription to "another/#". I wonder if there is a better approach or a better broker. – Plap Mar 21 '23 at 10:18

1 Answers1

6

You can not.

There is no way to query the broker for what topics the client has subscribed to in the protocol and in fact most MQTT client libraries don't even keep a list of subscribed topics for the current session.

hardillb
  • 54,545
  • 11
  • 67
  • 105