# No topic causes all MQTT nodes to disconnect

**URL:** <https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557>\
**Category:** General\
**Created:** [2 November 2023 17:31 UTC](https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557 "2023-11-02T17:31:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [2 November 2023 17:31 UTC](https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557/1 "2023-11-02T17:31:55Z")

</div>

Just noticed that injecting a message into MQTT out without setting a topic causes all MQTT nodes to disconnect for a few seconds.

I realise it should have a topic, but the node should really handle this more gracefully ?

It looks like the issue has been around for a few years -

> [@Publishing to a wildcard MQTT topic disconnects all MQTT nodes](https://discourse.nodered.org/t/publishing-to-a-wildcard-mqtt-topic-disconnects-all-mqtt-nodes/23244):
>
> While playing with MQTT in Node-RED, I accidentally configured an mqtt out node to publish to a topic with a wildcard: topic/+. [{"id":"ca140429.24cef8","type":"inject","z":"3ac27de3.268a52","name":"","topic":"topic/+","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":140,"wires":[["ec98b238.b0cea"]]},{"id":"ec98b238.b0cea","type":"mqtt out","z":"3ac27de3.268a52","name":"","topic":"","qos":"2","retain":"true","broker":"72393540.a2a3fc","x":410,"y…

---

<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:** [2 November 2023 21:03 UTC](https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557/2 "2023-11-02T21:03:50Z")

</div>

If you are using mosquitto then I think it may be that mosquitto disconnects you. In the mosquitto log I see  
`Client tigger disconnected due to malformed packet.`

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [2 November 2023 23:32 UTC](https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557/3 "2023-11-02T23:32:36Z")

</div>

I am using Mosquitto, but if there is no topic defined, I think the node should just show an error and not pass to the broker, since this then affects all flows.

---

<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:** [3 November 2023 00:00 UTC](https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557/4 "2023-11-03T00:00:04Z")

</div>

Can you raise an issue on github so we can track and resolve?

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [3 November 2023 00:13 UTC](https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557/5 "2023-11-03T00:13:58Z")

</div>

Done -

> <https://github.com/node-red/node-red/issues/4414>
>
> \### Current Behavior
> 
> I noticed that injecting a message into MQTT out node with…out setting a topic causes all MQTT nodes to disconnect for a few seconds.
> 
> I realise it should have a topic, but the node should really handle this more gracefully
> 
> \### Expected Behavior
> 
> The node should just show an error and the message should not be passed on to the broker, since this then affects all flows.
> 
> \### Steps To Reproduce
> 
> Just inject a msg without any topic set into an MQTT node configured without a topic.
> 
> \### Example flow
> 
> \`\`\`
> paste your flow here
> \`\`\`
> 
> 
> \### Environment
> 
> \- Node-RED version: 3.1.0
> \- Node.js version: 18.17.1
> \- npm version: 9.6.7
> \- Platform/OS: RPi Bullseye
> \- 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:** [2 January 2024 00:14 UTC](https://discourse.nodered.org/t/no-topic-causes-all-mqtt-nodes-to-disconnect/82557/6 "2024-01-02T00:14:42Z")

</div>

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