Reputation: 1287
I have a publisher, which sends a message under "/ex/topicA/" and an another publisher, which sends a message under "/ex/topicB/" to mosquitto broker.
The subscriber continuously subscribes from the broker under "/ex/#".
Now, due to poor network connection a publisher, which has a topic "/ex/topicA" is not sending data to mosquitto broker.
Now, How do the paho mqtt subscriber know which publisher is not sending data to mosquitto broker?
Upvotes: 0
Views: 523
Reputation: 59826
At a basic protocol level they don't.
Part of the point of Pub/Sub messaging is that it totally decouples the user producing the data from those consuming it.
A subscriber subscribes to a topic, there may never be a message published on that topic and they should not care which publisher sends that message. Likewise a publisher publishes message to a topic, there may be 0 to many clients subscribed to that topic.
If you REALLY need notifying that a client is on/off line then there are techniques to do this. The usual version is to have the client publish a retained message to a specific topic just after they connect. e.g. client/a/online
value 1
. They should include a Last Will and Testament message in the connection details that will publish 0
to this topic in the event of a unintentional disconnect. They would also manually publish 0
just before a instructed shutdown.
P.S. While valid in the spec, topics shouldn't start with /
as this adds a null entry in the topic tree at the start and breaks advanced features like Shared Subscriptions.
Upvotes: 3