# Are MQTT nodes allowed in Subflows?

**URL:** <https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690>\
**Category:** General\
**Created:** [7 January 2021 02:53 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690 "2021-01-07T02:53:55Z")\
**Posts on this page:** 10\
**Page:** 1

<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:** [7 January 2021 02:53 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/1 "2021-01-07T02:53:56Z")

</div>

Sorry, gotta ask to be sure.

I'm on a bit of a binge just now and am really playing with sub-flows.

I shall try it and see, but would like to be sure of my findings.

---

<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:** [7 January 2021 04:16 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/2 "2021-01-07T04:16:11Z")

</div>

Yes, they are allowed in sub flows,  
but I have since discovered there is a _trap_ if you use them:

## They don't get the new device's settings for the LWT (etc).

So not really advised for multiple machines.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 January 2021 07:58 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/3 "2021-01-07T07:58:29Z")

</div>

> [@Trying\_to\_learn](#):
>
> They don't get the new device's settings for the LWT (etc).

Can you explain a bit more what you mean by this?

There are no restrictions on using MQTT nodes inside a subflow.

---

<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:** [7 January 2021 08:02 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/4 "2021-01-07T08:02:40Z")

</div>

Ok.

I wrote/made a subflow.

Rather than having _outputs_ to then connect to other nodes - in this case `MQTT out` - I put them in the sub-flow.

It worked! Wow!

So I rolled it out over multiple machines, or: **Was about to**!

But when I pasted the code I saw the MQTT stuff and it has the settings from the other machine.

LWT, etc.

So at the MQTT level, its overheads would be wrong with who is sending the message, or what ever. Comms up, comms down, etc.

So I realised it isn't a good idea to put MQTT nodes in the sub-flow in **this** case.  
It would give erroneous message.

Does that help?

Do you want me to _show_ you with a dummy sub-flow?

---

<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:** [7 January 2021 10:03 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/5 "2021-01-07T10:03:13Z")

</div>

so there is no "trap". So we should remove that "solved" answer - as some readers may think that is a general statement when in fact it is just in your situation, and the answer is there are no restrictions.

---

<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:** [7 January 2021 10:03 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/6 "2021-01-07T10:03:56Z")

</div>

Well I wanted to "close" it, but I can't find how to do that.

---

<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:** [7 January 2021 10:05 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/7 "2021-01-07T10:05:00Z")

</div>

Well that is how you close it - but it is more helpful when the additional text is correct.

---

<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:** [7 January 2021 10:09 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/8 "2021-01-07T10:09:28Z")

</div>

There are no restrictions to using MQTT nodes inside subflows.

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [7 January 2021 11:42 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/9 "2021-01-07T11:42:02Z")

</div>

> [@dceejay](#):
>
> suing MQTT

I always find that litigation should be the last straw 😉

---

<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:** [21 January 2021 11:42 UTC](https://discourse.nodered.org/t/are-mqtt-nodes-allowed-in-subflows/38690/10 "2021-01-21T11:42:03Z")

</div>

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