# MQTT not reconnecting if only only one mqtt node using it

**URL:** <https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381>\
**Category:** General\
**Created:** [21 October 2022 13:28 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381 "2022-10-21T13:28:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 October 2022 13:28 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/1 "2022-10-21T13:28:52Z")

</div>

Could someone confirm an apparent bug that I am seeing please?

Starting with an empty flows file, configure a single MQTT In node (subscribing to a fixed topic) and a broker and deploy. Check it is working.

Change the topic subscribed to and do a partial deploy. On two systems here I am seeing that it disconnects and does not reconnect.

A Restart Flows fixes it.

If a second MQTT In node, using the same broker config, is added then the problem does not occur.

I am using node-red 3.0.2 and see this with node.js 16 and 18.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 October 2022 17:02 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/2 "2022-10-21T17:02:52Z")

</div>

Confirmed on an alternate installer install  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/7877d7ec74aa8eaf8afb4142d73a50a48c8b928a.png)

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [21 October 2022 18:51 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/3 "2022-10-21T18:51:44Z")

</div>

Indeed, doing exaclty like you said results in node not connecting after the partial deploy. Now, when i configure something as the close message this issue will not happen. Same for the will message.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 October 2022 19:13 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/4 "2022-10-21T19:13:22Z")

</div>

Thanks both for testing, I will submit an issue.  
It is amazing how a fundamental bug like that can go unnoticed, presumably for months if not longer.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 October 2022 19:43 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/5 "2022-10-21T19:43:20Z")

</div>

Well - its a fairly niche edge case 🙂

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 October 2022 19:50 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/6 "2022-10-21T19:50:39Z")

</div>

I suspect beginners will have fallen over it in their initial fiddling with MQTT but just assumed it was something they were doing wrong, then as soon as you add another MQTT node it goes away.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 October 2022 20:06 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/7 "2022-10-21T20:06:37Z")

</div>

> <https://github.com/node-red/node-red/issues/3927>
>
> \### Current Behavior
> 
> Starting with an empty flows file (though I am not sure ho…w important that is) create an MQTT In node which subscribes to a single topic, and create the associated broker config node, with everything at defaults.  
> 
> Deploy and check the MQTT node connects.
> 
> Edit the topic in the MQTT In node and do a Modified Nodes deploy. The node shows Disconnected.
> A full deploy or Restart Flows fixes it
> It has been reported by another in the linked forum thread below that configuring LWT messages stops the problem occuring. Also if another MQTT node uses the same config node then it does not happen.
> See forum thread https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381
> 
> 
> \### Expected Behavior
> 
> It should not disconnect from the broker
> 
> \### Steps To Reproduce
> 
> See above.
> 
> \### Example flow
> 
> \`\`\`
> paste your flow here
> \`\`\`
> 
> 
> \### Environment
> 
> \- Node-RED version: 3.0.2
> \- Node.js version: 16 and 18
> \- npm version:
> \- Platform/OS: Ubuntu
> \- Browser: Chrome

---

<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:** [20 December 2022 20:07 UTC](https://discourse.nodered.org/t/mqtt-not-reconnecting-if-only-only-one-mqtt-node-using-it/69381/8 "2022-12-20T20:07:32Z")

</div>

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