Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative number of disconnected clients on 2.0.14 #2466

Open
blusewang opened this issue Feb 24, 2022 · 3 comments
Open

Negative number of disconnected clients on 2.0.14 #2466

blusewang opened this issue Feb 24, 2022 · 3 comments
Labels
Component: mosquitto-broker Status: Available No one has claimed responsibility for resolving this issue. Type: Bug

Comments

@blusewang
Copy link

Hi,

I have an issue where I'm seeing negative numbers of inactive/disconnected clients. Any ideas about how that can happen?

mosquitto_sub -i cli-bluse -V mqttv5 -q 0 -L 'mqtts:https://xxxx/$SYS/#' -v
$SYS/broker/version mosquitto version 2.0.14
$SYS/broker/uptime 2701080 seconds
$SYS/broker/clients/total 21
$SYS/broker/clients/inactive -4
$SYS/broker/clients/disconnected -4
$SYS/broker/clients/active 25

And on Grafana:
image

@blusewang blusewang changed the title Negative number of inactive clients on 2.0.14 Negative number of disconnected clients on 2.0.14 Feb 24, 2022
@peteman720
Copy link

I'm seeing the same thing on version 2.0.13.

Also, the number of active and connected clients is much higher than should be possible with the number of devices that I have connected.

@ralight
Copy link
Contributor

ralight commented Aug 10, 2022

What is happening here, is that there are two tables internal to mosquitto used to generate those numbers. The first contains all of the client ids of clients that are on the broker. The second contains all of the network sockets of clients that are connected to the broker.

The list of client ids includes all clients - which means those currently connected and those that have persistent sessions that are not currently connected.

The list of network sockets includes all clients that currently have a network connection open with the broker, regardless of whether they have sent a CONNECT packet, for example. @peteman720 - if you have clients that are connecting slowly, or not sending their CONNECT for some reason, or have a long keepalive and have subsequently lost their network connection without the broker noticing, then you will end up with a greater number of connected clients than you would expect.

It is also this same sort of case that leads to negative numbers of disconnected clients. That is calculated using a simple "count of client ids" - "count of sockets", which is clearly not going to work in the case I've described above.

I'm not sure what the best solution is, it would be nice to fix but I don't want to add a chunk of complexity to do so.

@ralight ralight added Type: Bug Component: mosquitto-broker Status: Available No one has claimed responsibility for resolving this issue. labels Aug 10, 2022
@blusewang
Copy link
Author

Uh..... Well, thank's, at least I had know the reason.
Hope eclipse can provide more manpower on this project. there are too many issue stack up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: mosquitto-broker Status: Available No one has claimed responsibility for resolving this issue. Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants