# Inject node triggers automatically when MQTT device connects. Is this normal and expected behavior

**URL:** https://discourse.nodered.org/t/inject-node-triggers-automatically-when-mqtt-device-connects-is-this-normal-and-expected-behavior/13320
**Category:** General
**Created:** [15 July 2019 20:52 UTC](https://discourse.nodered.org/t/inject-node-triggers-automatically-when-mqtt-device-connects-is-this-normal-and-expected-behavior/13320 "2019-07-15T20:52:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MattCohen](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@MattCohen](https://discourse.nodered.org/u/MattCohen)
#### Post date: [15 July 2019 20:52 UTC](https://discourse.nodered.org/t/inject-node-triggers-automatically-when-mqtt-device-connects-is-this-normal-and-expected-behavior/13320/1 "2019-07-15T20:52:56Z")

</div>

Hi,

I was pulling my hair out with a small ESP32 device that seemed to be occasionally entering a state unexpectedly. After several hours of debugging I found that as the device came online it received several messages from node red from nodes I had wired up for testing previously. These nodes were just inject nodes connected directly to MQTT output nodes.  
Is this the expected behavior. It doesn't seem right to me.

I am keen to understand why this would be happening.

Thanks in Advance

Matt

---

<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: [15 July 2019 20:56 UTC](https://discourse.nodered.org/t/inject-node-triggers-automatically-when-mqtt-device-connects-is-this-normal-and-expected-behavior/13320/2 "2019-07-15T20:56:24Z")

</div>

Hi @MattCohen,

it sounds like you have some retained messages published to the topics your device is subscribing to.

This will cause the broker to resend them whenever the device connects and subscribes - this isn't Node-RED's doing.

You can clear retained messages by publishing another retained message with an empty payload to those same topics.

[https://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages/](https://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages/)
