# How to retrieve the status of my mqtt

**URL:** <https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051>\
**Category:** General\
**Tags:** mqtt\
**Created:** [17 May 2024 08:19 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051 "2024-05-17T08:19:56Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 May 2024 09:46 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/21 "2024-05-17T09:46:25Z")

</div>

> [@Paul](#):
>
> I'd like to set up something like a ping that tests the communication between MQTT and Node-RED every 5 seconds, for instance. If the ping doesn't return, I'd receive an email.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef855ce0600c5ee89a9ce3d9fb4be6a92400d49e.png)

This does have the advantage over LWT that it's on your own system, so if the MQTT broker goes down you have the chance of noticing.

But if your internet connection goes down you can't send an email.

To catch that event you could have the second part of the flow repeated on another machine on a different network.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 May 2024 10:05 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/22 "2024-05-17T10:05:41Z")

</div>

There is a great tutorial [MQTT Essentials - All Core Concepts Explained](https://www.hivemq.com/mqtt-essentials/) you should read. It will give you a better understanding of how it works and the terminology that is used.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 May 2024 10:18 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/23 "2024-05-17T10:18:20Z")

</div>

On your original flow... Note... the status node reports it's information on msg.status and not msg.payload - so your switch needs to monitor msg.status....

---

<div class="post-metadata">

**Author:** ![kitori](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kitori](https://discourse.nodered.org/u/kitori)\
**Post date:** [17 May 2024 11:16 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/24 "2024-05-17T11:16:30Z")

</div>

Because of some difficult networks where i deploy some maschines, i use a public reachable [https://github.com/louislam/uptime-kuma](https://github.com/louislam/uptime-kuma) instance with a push monitor(alternative [https://healthchecks.io/](https://healthchecks.io/) ) to monitor my devices:

so you can add a http request node to the mqtt subscribe node to ping the http endpoint. Then you get a notification when the local internet is down.

---

<div class="post-metadata">

**Author:** ![Paul](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul](https://discourse.nodered.org/u/Paul)\
**Post date:** [29 May 2024 07:18 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/25 "2024-05-29T07:18:24Z")

</div>

Hello, I'm sorry for not having responded. Do you know where I can find a guide to understand how to set it up and what to fill in the fields?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 07:23 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/26 "2024-05-29T07:23:52Z")

</div>

> **[mqtt-v3.1.1-os.pdf](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.pdf)**
>
> 2.16 MB

This may help.

Or:

> **[MQTT](https://en.wikipedia.org/wiki/MQTT)**
>
> MQTT (originally an initialism of MQ Telemetry Transport\[a\]) is a lightweight, publish-subscribe, machine to machine network protocol for message queue/message queuing service. It is designed for connections with remote locations that have devices with resource constraints or limited network bandwidth, such as in the Internet of Things (IoT). It must run over a transport protocol that provides ordered, lossless, bi-directional connections—typically, TCP/IP, but also possibly over QUIC. It i Andy ...

Or:

[http://www.steves-internet-guide.com/mqtt/](http://www.steves-internet-guide.com/mqtt/)

Or:

> **[MQTT Explained: The Complete Guide](https://cedalo.com/blog/complete-mqtt-protocol-guide/)**
>
> This complete MQTT guide delves into the fundamentals of the protocol, its main elements, and how its function can benefit IoT communication.

I'm not sure exactly what part of it you need help.

Or maybe this:

> **[Introducing the MQTT Protocol – MQTT Essentials: Part 1](https://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt/)**
>
> What is MQTT, what does MQTT stand for, & why should you use MQTT in IoT or IIoT? Get answers to all these questions here.

Free public MQTT broker available too.

---

<div class="post-metadata">

**Author:** ![Paul](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul](https://discourse.nodered.org/u/Paul)\
**Post date:** [29 May 2024 07:25 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/27 "2024-05-29T07:25:43Z")

</div>

Hello,

Thank you for your response, which seems interesting to me. Is the software paid? I see that the server is a demonstration server. How did you implement it in Node-RED?

---

<div class="post-metadata">

**Author:** ![Paul](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul](https://discourse.nodered.org/u/Paul)\
**Post date:** [29 May 2024 07:32 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/28 "2024-05-29T07:32:52Z")

</div>

Thank you for your documentation. I need help to understand and to know what I need to fill in.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/13408a6fdfe81b5435a12b988a4d50d6ae5e7b92.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 07:33 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/29 "2024-05-29T07:33:03Z")

</div>

MQTT is free.

The program, the protocol and all parts.

The only _paid_ part is the `broker`.  
But there are free ones out there too.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 07:35 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/30 "2024-05-29T07:35:58Z")

</div>

You need to look at the first tab.

That one is the THIRD one.

`connection`.

There isn't much there either.

Only the IP address of the `broker`.

The `MQTT IN` and `MQTT OUT` nodes are the ones you need to do things with.

---

<div class="post-metadata">

**Author:** ![Paul](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul](https://discourse.nodered.org/u/Paul)\
**Post date:** [29 May 2024 07:36 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/31 "2024-05-29T07:36:17Z")

</div>

Yes, I understand, but I was referring to his proposition of "uptime-kuma." I was wondering if the service is paid.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 07:37 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/32 "2024-05-29T07:37:42Z")

</div>

hivemq have a free broker.

> [@Paul](#):
>
> uptime-kuma.

Mind showing me where this is?

---

<div class="post-metadata">

**Author:** ![Paul](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul](https://discourse.nodered.org/u/Paul)\
**Post date:** [29 May 2024 07:39 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/33 "2024-05-29T07:39:31Z")

</div>

Steve told me earlier in the discussion that to receive a message upon server disconnection, it's configured here. That's why I asked him if he knew what I needed to fill in for it to work and for me to understand how it works for future reference.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 07:40 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/34 "2024-05-29T07:40:15Z")

</div>

Install a MQTT BROKER on one of your machines - Ubuntu/similar preferred.

Then you can learn and not worry about anything.

EVERYTHING will be in your control.

I learnt in about 3 hours.

---

<div class="post-metadata">

**Author:** ![Paul](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul](https://discourse.nodered.org/u/Paul)\
**Post date:** [29 May 2024 07:41 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/35 "2024-05-29T07:41:46Z")

</div>

Kitori told me

Because of some difficult networks where i deploy some maschines, i use a public reachable [GitHub - louislam/uptime-kuma: A fancy self-hosted monitoring tool](https://github.com/louislam/uptime-kuma) instance with a push monitor(alternative [https://healthchecks.io/](https://healthchecks.io/) ) to monitor my devices:

so you can add a http request node to the mqtt subscribe node to ping the http endpoint. Then you get a notification when the local internet is down.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 07:42 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/36 "2024-05-29T07:42:50Z")

</div>

I am not exactly sure how to describe how to do that with an EXTERNAL broker.

On my LOCAL broker I do this - example:

 ![Screenshot from 2024-05-29 17-41-58](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd188c7b2fdb7540eec0cb2c836ecc9020dae18a.png)

From that last link I posted:

> **[What is MQTT Last Will and Testament (LWT)? – MQTT Essentials: Part 9](https://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament/)**
>
> Learn the basics of MQTT Last Will and Testament (LWT) & how it helps maintain system integrity in the event of unexpected client disconnections.

```auto
When does the MQTT Broker Send the LWT Message?

According to the MQTT 3.1.1 specification, the broker sends a client’s Last Will and Testament (LWT) message in the following situations:

    I/O error or network failure: If the broker detects any issues with the input/output or network connection, it will distribute the LWT message.

    Failed communication within Keep Alive period: If the client fails to communicate with the broker within the specified Keep Alive period, the LWT message is sent. In Part-10 of our MQTT Essentials, we will explore the concept of MQTT Keep Alive time and delve into its significance it.

    Client closes connection without DISCONNECT: When the client terminates the network connection without sending a DISCONNECT packet, the broker ensures the LWT message is distributed.

    Broker closes connection due to protocol error: If the broker closes the network connection due to a protocol error, it will send the LWT message.

Understanding when and why the broker sends the Last Will and Testament (LWT) messages lays the groundwork for implementing best practices in leveraging this feature, which we will delve into in the next section.

```

---

<div class="post-metadata">

**Author:** ![Paul](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul](https://discourse.nodered.org/u/Paul)\
**Post date:** [29 May 2024 07:49 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/37 "2024-05-29T07:49:29Z")

</div>

Alright, I understand, thank you. Have you added any other parameters or just those? Because I have additional parameters, and how do you handle the payload you receive? Is it in a debug? Is it possible to receive it via email? Or is the payload only visible in the MQTT server?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 07:52 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/38 "2024-05-29T07:52:54Z")

</div>

No.

The messages are sent with the given conditions are met.

The message is received with the `topic` of `EOM` (Which is a stuff up, it should have been `EOL`, but anyway....)

To I have a `MQTT IN` node with the `topic` of `EOM`.

Any messages received in that node is that machine's EOM message.  
Sorry, the BROKER's message.

I'm getting confused now.  
But I suspect that is what you want.

# **Ok, sorry.**

This is on ANOTHER machine which uses/talks to the other BROKER

 ![Screenshot from 2024-05-29 17-53-27](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f3fd34096cdf8935b3e1788ce84ac1321986191.png)

So on each machine you have to _define_ the `broker`.

So here you see I am using TIMEPI  
This is TELEPI.

So on `TELEPI` when I set up the `broker` I put in `TIMEPI` IP address, (in the first tab) then on the third tab I do this with the name `TELEPI`.

So if the link fails between TIMEPI and TELEPI:  
TIMEPI broadcasts a message on the `EOM` topic and you can process that and see _who died_, and act accordingly.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 May 2024 08:15 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/39 "2024-05-29T08:15:12Z")

</div>

Set up a broker.  
Local or remote.

All devices talk to eachother via the BROKER.

On each of your devices configure the broker - setting the IP address.  
On the third tab (messages) set up the bottom one with a TOPIC (I chose EOL) and a message that will identify the machine.

If the link from the BROKER to that machine fails the BROKER will send out a message containing the message you entered above.  
So you have a `MQTT IN` node _subsribing_ to that `topic`.  
Do this on ANOTHER machine.

Break the link to the _other_ machine.  
Wait for the time out and you will/should see the message arrive via that `MQTT IN` node.  
You then add code (nodes) there to alert you that that machine has died.

Having a LOCAL BROKER you can do this on the BROKER machine.  
But if you use a REMOTE one, you can't.

This is a graphical attempt to explain what I said.  
(given that "machine 1" is the problematic one.)  
and "machine 2" is another local machine.

 ![MQTT overview](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d6f6d0e8b8a41118a8cfdbf9500997172f30f2c0.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [29 May 2024 08:46 UTC](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051/40 "2024-05-29T08:46:32Z")

</div>

I am rather puzzled by all this focus on the MQTT LWT message.

@Paul seems to believe that the broker is going down.  
If that happens, nobody is going to be sending out LWT messages.

The LWT message will be issued, after a couple of minutes, if _Paul's device_ goes down or looses internet connection.  
He would have to be monitoring that topic from a third machine since his will be off-line when it is published. (The behaviour might be different if the birth, death and last will messages are persistent, which I advise against)

If it's the broker that's unreliable, he should be tracking the Birth message which will be issued when either the broker or his own server comes back on line.

[Previous page](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051.md?page=1)

[Next page](https://discourse.nodered.org/t/how-to-retrieve-the-status-of-my-mqtt/88051.md?page=3)
