# Retain on MQTT Node not working

**URL:** <https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283>\
**Category:** General\
**Created:** [26 May 2021 13:59 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283 "2021-05-26T13:59:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)\
**Post date:** [26 May 2021 13:59 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/1 "2021-05-26T13:59:18Z")

</div>

Hello Folks,

I have recently been using the MQTT node on Node Red yet trying to use the retain functionality on the Node.

Has anyone else had issues that when using the retain function no data is updated on that specific topic?

Thank you,

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 May 2021 14:13 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/2 "2021-05-26T14:13:36Z")

</div>

What broker are you using?

> [@edwardr](#):
>
> Has anyone else had issues that when using the retain function no data is updated on that specific topic?

Do you know how retain works?

---

<div class="post-metadata">

**Author:** ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)\
**Post date:** [26 May 2021 14:32 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/3 "2021-05-26T14:32:24Z")

</div>

Yes, retain keeps the latest message on file and then when a new subscriber connects to the topic he/she will get that latest message?

For context - I have a mqtt set up with QoS 0 and retain false - the issue I`m having is when people connect to such after a while no data is shown on MQTT as it forgets it , but when I put it as retain true no data changes.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 May 2021 14:50 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/4 "2021-05-26T14:50:30Z")

</div>

So what broker are you using?

Does retained messages appear on any / other clients?

Are you using MQTT v5? with a **message expiry interval**?

> [@edwardr](#):
>
> For context - I have a mqtt set up with QoS 0 and retain false - the issue I`m having is when people connect to such after a while no data is shown on MQTT as it forgets i

Is that a typo? If you set "retain false", the new subscribers wont get a retained message.

---

<div class="post-metadata">

**Author:** ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)\
**Post date:** [26 May 2021 14:56 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/5 "2021-05-26T14:56:30Z")

</div>

No it doesnt appear on any other clients,

I am using Mqtt v5 Aws , but I am unsure how to check the message expiry interval - any advise how to find this?

No typo. The message must be expiring after a set time.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 May 2021 14:59 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/6 "2021-05-26T14:59:55Z")

</div>

It was my understanding AWS doesn't support MQTT v5?

Have you tried with a local broker (or is node-red also running in AWS)?

---

<div class="post-metadata">

**Author:** ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)\
**Post date:** [26 May 2021 15:02 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/7 "2021-05-26T15:02:45Z")

</div>

Node red is running with the AWS broker - apologises I thought this was MQTT v5.

Does this mean I can`t retain messages?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 May 2021 15:05 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/8 "2021-05-26T15:05:31Z")

</div>

> [@edwardr](#):
>
> Does this mean I can`t retain messages

No. It means it's not doing "message timeout interval" (since that is a v5 feature)

You need to look into AWS and retained messages. Try their forums.

I can say is mqtt and retained messages work perfectly well on mine and thousands of other systems. The difference is you are on AWS.

---

<div class="post-metadata">

**Author:** ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)\
**Post date:** [26 May 2021 15:08 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/9 "2021-05-26T15:08:39Z")

</div>

Ah okay so just checking online AWS doesn`t actually support retain messages and instead disconnects from the device.

I will do some digging re if there is a message timeout interval instead.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 July 2021 15:08 UTC](https://discourse.nodered.org/t/retain-on-mqtt-node-not-working/46283/10 "2021-07-25T15:08:39Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
