# Publishing to a wildcard MQTT topic disconnects all MQTT nodes

**URL:** <https://discourse.nodered.org/t/publishing-to-a-wildcard-mqtt-topic-disconnects-all-mqtt-nodes/23244>\
**Category:** General\
**Created:** [17 March 2020 19:36 UTC](https://discourse.nodered.org/t/publishing-to-a-wildcard-mqtt-topic-disconnects-all-mqtt-nodes/23244 "2020-03-17T19:36:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![techraf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/techraf/32/17389_2.png) [@techraf](https://discourse.nodered.org/u/techraf)\
**Post date:** [17 March 2020 19:36 UTC](https://discourse.nodered.org/t/publishing-to-a-wildcard-mqtt-topic-disconnects-all-mqtt-nodes/23244/1 "2020-03-17T19:36:40Z")

</div>

While playing with MQTT in Node-RED, I accidentally configured an `mqtt out` node to publish to a topic with a wildcard: `topic/+`.

```auto
[{"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":140,"wires":[]},{"id":"72393540.a2a3fc","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

When doing so, all MQTT in and out nodes within a project disconnected and reconnected after few seconds (causing retained messages to be injected into NR flow―which, ironically, was what I was looking for at the time). It seems to me like crashing an MQTT subsystem (?).

It doesn't look to me as intended―shouldn't `mqtt out` node check and prevent publishing to topics with `+` and `#` by raising an error, instead of crashing (disconnecting) all MQTT nodes?

---

<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:** [18 March 2020 08:50 UTC](https://discourse.nodered.org/t/publishing-to-a-wildcard-mqtt-topic-disconnects-all-mqtt-nodes/23244/2 "2020-03-18T08:50:22Z")

</div>

Yes I would think a check should be in order - please raise an issue against the main project so we can track and fix.

---

<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:** [17 May 2020 08:50 UTC](https://discourse.nodered.org/t/publishing-to-a-wildcard-mqtt-topic-disconnects-all-mqtt-nodes/23244/3 "2020-05-17T08:50:24Z")

</div>

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