# Examples that publish/subscribe MQTT?

**URL:** <https://discourse.nodered.org/t/examples-that-publish-subscribe-mqtt/7320>\
**Category:** Developing Nodes\
**Created:** [28 January 2019 01:26 UTC](https://discourse.nodered.org/t/examples-that-publish-subscribe-mqtt/7320 "2019-01-28T01:26:30Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![ScottChapman](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scottchapman/32/4838_2.png) [@ScottChapman](https://discourse.nodered.org/u/ScottChapman)\
**Post date:** [29 January 2019 14:34 UTC](https://discourse.nodered.org/t/examples-that-publish-subscribe-mqtt/7320/13 "2019-01-29T14:34:08Z")

</div>

So I had some thought on my drive in (it's not a long drive, so I haven't thought this through completely!).

It is clear that there is an attempt to allow custom nodes to share MQTT connections within Node Red; I think this is great. But for reasons above it is not possible for custom nodes to know when the connection changes.

I think this could be addressed by doing just two things:

1. Promoting connection related events to all registered nodes
2. When a node is registered, fire the current connection state to the newly registered node.

Thoughts?

---

_[View the full topic](https://discourse.nodered.org/t/examples-that-publish-subscribe-mqtt/7320)._
