Can't remove device to my mqtt broker

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 ?

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

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.

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.

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.

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

Where are you getting this message?

@knolleary okay

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

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

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

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

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

Exactly @knolleary

@Colin pardon, 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.