# Can't remove device to my mqtt broker

**URL:** <https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574>\
**Category:** General\
**Created:** [6 November 2019 07:22 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574 "2019-11-06T07:22:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![1522](https://avatars.discourse-cdn.com/v4/letter/1/e79b87/32.png) [@1522](https://discourse.nodered.org/u/1522)\
**Post date:** [6 November 2019 07:22 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/1 "2019-11-06T07:22:56Z")

</div>

Hello there, i have a doubt. My question is suppose When i connect 10 device with Mqtt broker, in my server it shows that 10 device are connected. Now suppose i am done with 3 devices and i remove it after 20-30 second in my server it still showing that my mqtt-borker pointing 10 devices, though i remove that 3 device. It should show 7 devices are connected, but getting message that 10 device are connected in my server. How we can remove that unused device Permanently?  
Do you know a way to fix this ?

---

<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:** [6 November 2019 07:53 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/2 "2019-11-06T07:53:24Z")

</div>

What broker are you using? Where does it show information about connected devices?

---

<div class="post-metadata">

**Author:** ![1522](https://avatars.discourse-cdn.com/v4/letter/1/e79b87/32.png) [@1522](https://discourse.nodered.org/u/1522)\
**Post date:** [6 November 2019 08:18 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/3 "2019-11-06T08:18:33Z")

</div>

i am using Mosca .  
Information i am getting in my server. Though i removed the devices, but it still pointing to all the devices that are connected over same network.

---

<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:** [6 November 2019 08:40 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/4 "2019-11-06T08:40:22Z")

</div>

> [@1522](#):
>
> i am using Mosca .

Unless someone here is familiar with mosca, then I'm not sure how much help we can be.

One thought is if you are connecting the clients with the clean session flag or not. If not, then the broker will be storing state for the clients whilst they are disconnected and that may account for what you see.

Assuming your clients are node-red instances, the 'clean session' option is in the mqtt-broker config node - although it defaults to true.

---

<div class="post-metadata">

**Author:** ![1522](https://avatars.discourse-cdn.com/v4/letter/1/e79b87/32.png) [@1522](https://discourse.nodered.org/u/1522)\
**Post date:** [6 November 2019 09:00 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/5 "2019-11-06T09:00:00Z")

</div>

ok, i will check clean session is flag or not.  
One More thing. Is there any other way that we can do with mqtt broker or on server to get rid of the problem.  
Because i permanently wants to remove the unused device until unless i add them.  
One solution is there to reboot the server again and again.  
But its not possible to reboot the server every time when i remove a device.

---

<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:** [6 November 2019 09:08 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/6 "2019-11-06T09:08:42Z")

</div>

You'd have to check the mosca docs for what choices you have to administratively tidy anything up.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 November 2019 09:15 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/7 "2019-11-06T09:15:57Z")

</div>

> [@1522](#):
>
> but getting message that 10 device are connected in my server.

Where are you getting this message?

---

<div class="post-metadata">

**Author:** ![1522](https://avatars.discourse-cdn.com/v4/letter/1/e79b87/32.png) [@1522](https://discourse.nodered.org/u/1522)\
**Post date:** [6 November 2019 09:17 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/8 "2019-11-06T09:17:35Z")

</div>

@knolleary okay

---

<div class="post-metadata">

**Author:** ![1522](https://avatars.discourse-cdn.com/v4/letter/1/e79b87/32.png) [@1522](https://discourse.nodered.org/u/1522)\
**Post date:** [6 November 2019 09:19 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/9 "2019-11-06T09:19:07Z")

</div>

On my Server, it still showing that all 10 device were connected.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 November 2019 09:21 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/10 "2019-11-06T09:21:03Z")

</div>

I meant where is the message coming from - where are you looking that shows the number of connected clients - I've setup this test flow but struggling to find that out

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e469a2b61be8b5376b7f5d5b81fd6a5338e9b53a.png)

---

<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:** [6 November 2019 10:21 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/11 "2019-11-06T10:21:42Z")

</div>

> [@cymplecy](#):
>
> I meant where is the message coming from - where are you looking that shows the number of connected clients - I've setup this test flow but struggling to find that ou

It is being reported by the broker - nothing to do with Node-RED.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 November 2019 10:35 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/12 "2019-11-06T10:35:25Z")

</div>

Sorry - I assumed they were using NR mosca node and not just running it using node.js directly

---

<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:** [6 November 2019 11:01 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/13 "2019-11-06T11:01:02Z")

</div>

Why does it matter how many clients the broker thinks are connected?

---

<div class="post-metadata">

**Author:** ![1522](https://avatars.discourse-cdn.com/v4/letter/1/e79b87/32.png) [@1522](https://discourse.nodered.org/u/1522)\
**Post date:** [6 November 2019 11:53 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/16 "2019-11-06T11:53:30Z")

</div>

Exactly @knolleary

---

<div class="post-metadata">

**Author:** ![1522](https://avatars.discourse-cdn.com/v4/letter/1/e79b87/32.png) [@1522](https://discourse.nodered.org/u/1522)\
**Post date:** [6 November 2019 11:55 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/17 "2019-11-06T11:55:03Z")

</div>

@Colin pardon, i didn't get you.!!

---

<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:** [6 November 2019 12:28 UTC](https://discourse.nodered.org/t/cant-remove-device-to-my-mqtt-broker/17574/18 "2019-11-06T12:28:50Z")

</div>

> [@1522](#):
>
> i didn't get you.!!

You seem to be complaining that the broker does not see that clients have disconnected. As far as you have indicated the only way you see this is by looking at the broker log or some display that broker provides that tells you how many clients are connected. So why does it matter? Presumably you are somehow interrogating that number in node red. So how are you getting that from the broker and why does it matter.
