# Creating a config node

**URL:** <https://discourse.nodered.org/t/creating-a-config-node/85370>\
**Category:** Developing Nodes\
**Created:** [9 February 2024 14:59 UTC](https://discourse.nodered.org/t/creating-a-config-node/85370 "2024-02-09T14:59:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [9 February 2024 14:59 UTC](https://discourse.nodered.org/t/creating-a-config-node/85370/1 "2024-02-09T14:59:29Z")

</div>

I'm making a config node that creates a tcp connection. If there is no node using the config node we created, the config should not create a TCP connection. How do I solve this problem?

So how can I find out the number of nodes using this config node?

---

<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:** [9 February 2024 15:24 UTC](https://discourse.nodered.org/t/creating-a-config-node/85370/2 "2024-02-09T15:24:49Z")

</div>

Hi @sercancetin

Have a look at how the `mqtt-broker` config node handles this scenario.

It provides a pair of `register` and `deregister` functions that the regular `mqtt in` and `mqtt out` nodes can call as part of the normal lifecycle to notify the config node of their existence.

The config node can then decide if and when to start and stop the underlying connection.

Here's the `register` function:

> <https://github.com/node-red/node-red/blob/b10ef4c98ce8bf1b61584a046fdb4bc90d485295/packages/node_modules/%40node-red/nodes/core/network/10-mqtt.js#L722>

---

<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:** [9 April 2024 15:25 UTC](https://discourse.nodered.org/t/creating-a-config-node/85370/3 "2024-04-09T15:25:49Z")

</div>

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