MQTT: Topic status

441 views
Skip to first unread message

GEPD

unread,
Sep 8, 2016, 6:24:43 PM9/8/16
to Node-RED
Hi guys, I need a little help getting the right status in a MQTT node.

I'm using Node-red v0.14.6 and some nodemcu with ESPEasy. The doubt I'm having maybe it's not directly related with node-red, so I will be grateful with any help about this "issue"

I haven't problem receiving the data sent by the nodemcu. Reading this page in the node-red documentation, I assumed I can know the state of the node (device) when it's on or off. But when I disconnect any device from the network, node-red keep showing it as online. At the beginning of the documentation page say: "the MQTT nodes can indicate if they are currently connected or not." and the image shows two nodes one called "topic/one" (online) and other "topic/two" offline.

Why is my device keep as online? did I have to activate some option as "birth message"?

Can anyone explain me a little bit how should I set this configuration?

Thanks!

Nicholas O'Leary

unread,
Sep 8, 2016, 6:35:53 PM9/8/16
to Node-RED Mailing List
Hi,

the status of the mqtt node reflects the connection status of node-red to your MQTT broker. That is independent of whether you have any other clients (devices) connected to the broker as well.

MQTT provides no built-in mechanism for one client to know if another is currently connected. You have a build such awareness in at your application level. There's an outline of how you can do that here: https://github.com/mqtt/mqtt.github.io/wiki/presence

Nick


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Mark Setrem

unread,
Sep 8, 2016, 6:42:39 PM9/8/16
to Node-RED


Another way to do it would be by pinging them (if they have a fixed ip) using http://flows.nodered.org/node/node-red-node-ping

GEPD

unread,
Sep 8, 2016, 6:53:37 PM9/8/16
to Node-RED
Thanks both of you for your answer. I suspected the online status was about the broker but for some reason the documentation confused me a little bit. I'll try both option to get what I want, thanks again!

Julian Knight

unread,
Sep 9, 2016, 5:02:55 AM9/9/16
to Node-RED
I use a combination of things to monitor online/offline status via MQTT.

I use ping, tcping (to check a services port), arp to check for device presence - all of these create a heartbeat MQTT message for the specific device - the heartbeat messages have a last will and testament setting so that too long a period between pings automatically sets the status message to Offline.

For my ESP devices, these connect directly to MQTT so have their own heartbeat sent directly. Again, the LWT setting automatically marks the devices as offline if the heartbeat isn't recieved. I generally use a 60s timeout since that is the refresh rate I tend to use for sensor updates.
Reply all
Reply to author
Forward
0 new messages