MQTT Client sessions total

I’m currently evaluating HiveMQ cloud using a free Cluster.
I have less than 10 devices connected (mix of client devices and a web server) and all are using a fixed MQTT ID.
However, I am seeing the Client Sessions as 100 (maxed out), and I’m not sure what happened to create so many connections. To debug, I’ll need to see the client IDs that are connected, but on HiveMQ cloud there does not seem to be a way the check this.

My questions are:

  1. How is the total Client sessions counted? Total number of persistent connections?
  2. Is there a way to list the client IDs that are or have connected?
  3. Does this total clear periodically?
  4. Can I manually clear unused Clients?

If this gets stuck at 100 forever, I will end up never be able to connect new devices to the broker.

Hi @EugeneG,

I will try to answer your questions to my current knowledge.

  1. How is the total Client sessions counted? Total number of persistent connections?

A: Offline persistent clients + any online client

  1. Is there a way to list the client IDs that are or have connected?

A: Currently not

  1. Does this total clear periodically?

A: As the max data retention time is three days, worst case → after a client has gone offline you have to wait three days until the session is cleaned up

  1. Can I manually clear unused Clients?

A: You could do that if you would know the used client ids that create the sessions, basically you would connect with the already used client ids but with a “clean” session

As 2. is currently not an option to achieve step 4. my suggestion is to write an e-mail to and ask if they can provide you with a list containing all the client id’s that are currently associated with your account (maybe reference this thread).

Michael from the HiveMQ team

Hi @michael_w

Thanks for the reply.
I’ve figured the cause of the problem, which was (as I assumed) our issue, where some clients were connecting with random IDs without clean sessions and causing the slots to be filled up.
However, as these random IDs have not been used again, I would expect them to be purged from the cluster after 3 days, but the count is not going down and still stuck at 100.

I need to decide by this week as we need to move into a Pay-as-you-go account to start actively using their service in a production project.
Does it really clean up at 3 days or monthly or never?
Monthly would make sense, to match a paid account’s billing cycle. Getting stuck forever would be a major drawback.

Can anyone from HiveMQ help with this question?

Hi @EugeneG,

sorry for the delay. My three day information was wrong and I already got this answered internally correctly before I wrote my above reply (mea culpa). So I just copy a part of the answer I got:

In the answer we must include the info, that the number will be reset at the end of the month.

Michael from the HiveMQ team

Hi @michael_w
Noted with thanks. That makes a lot of sense actually from the point of a monthly billing cycle.
I’ll wait till the end of the month and see. The count should reset to 0 as I have nothing connected to that cluster right now.


Interesting question, as I am facing the same problem with my free cloud subscription.

My mqtt .net framework client keeps Connecting and Disconnecting over and over again.

It could be because (as mentioned earlier) I was creating a new random ClientID upon each connection (and I’m testing and debugging many many times).

And I just discovered in my OnSubscriberDisconnected method that the ReasonString = Another client connected with the same client id. and Reason = SessionTakenOver

Of course I have Dashboard to see the currently connected clients, as you mentioned at the top.

I’ll try and create all new clientID sessions with CleanSession = true.

For future reference of anyone who has the same issue, I’ll confirm that the count reset to zero at the end of the month.
Best to just be careful on making connections. I believe every random MQTT id counts to the total, so it may not be best practice to use random IDs.
I’ll experiment a bit with cleansession = true, just to satisfy my curiosity if clean sessions are also held till the end of the month.

@EugeneG I’m facing the connect/disconnect loop in my Window Service project, via the Mqtt .Net client v4.1.4. Of course I cannot see the list of client connections to my broker instance/cluster, but the disconnect reason in my Conn/Disconn handler is Another client connected with the same client id.
I’m also connecting with CleanSession: true

This means the broker initiated the disconnection based on the Client Take-Over Mechanism.
Typically a loop is caused by a client losing its connection and re-connecting before the broker could detect the same connection loss.

I’d suggest checking what “Keep Alive” value the client sets when sending the CONNECT packet. You might want to set a lower value for “Keep Alive” and see if that improves the situation.

I hope it helps.
Kind regards,
Dasha from HiveMQ Team

1 Like

I believe the reason was my mistake in my c# code. I generate a clientID based on the unique machine name, and I was using the same ID for both sub and pub. I commented out the pub code for the time being, and of course the error stopped happening. Thanks for your answer.