mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

How does Mosquitto determine the online and offline status of devices by using its built-in topics?

Open objectboy2016 opened this issue 2 months ago • 1 comments

Was there no specific topic for determining the client's online/offline status in Mosquitto 2.0.22? I looked up some information which stated that $SYS/broker/client/[clientid]/connected can indeed be used to determine whether the connection is online or offline. However, when I actually tried to use it, it didn't work as expected. Could you please tell me what steps I need to take to use Mosquitto properly? thank you

objectboy2016 avatar Nov 04 '25 03:11 objectboy2016

@objectboy2016 I'm afraid that information is wrong, there is no built in mechanism in the broker for doing this. It's fairly straightforward to have your clients do this themselves though - set a will message to publish a retained 0 to a topic, then on connect publish a retained 1 to that same topic.

ralight avatar Nov 04 '25 09:11 ralight