Mqtt list is showing only one client while I have several connected

I am using MQTT CLI to connect to a HiveMQ CE broker. There are around 10+ topics being published on the broker and 4 ~5 total clients are connected (2 pub and 2 sub from remote devices) and 1 sub from my CLI. When i do a list command only the one connected from CLI is shown :woozy_face:

TERM1@mqtt.mindshiftapps.net> ls --long -s
total 1
CONNECTED 18:48:58 TERM1 mqtt.mindshiftapps.net  1883 MQTT_5_0 NO_SSL        
 -subscribed topics: []
TERM1@mqtt.mindshiftapps.net> 

If i login to the hivemq broker with ssh (yes it is hosted on an ubuntu server) and check the event log on command line of linux, it shows all the connection events.

oot@ubuntu-s-1vcpu-1gb-blr1-01:/opt/hivemq/log# 
root@ubuntu-s-1vcpu-1gb-blr1-01:/opt/hivemq/log# tail event.log
2022-05-05 13:24:00,489 - Client ID: mosq-K8Qo5tc5E0BrzNd885, IP: 42.105.49.112, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:24:00,493 - Client ID: mosq-Wuv9ZBrYsVfxxK9vgH, IP: 42.105.49.112, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:24:00,510 - Client ID: mosq-vCRg5IioqjHFXEXrRd, IP: 42.105.49.112, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:24:00,511 - Client ID: mosq-lMEkAz3O88auSVwClH, IP: 42.105.49.112, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:24:00,511 - Client ID: mosq-Ty5K0MtqIKEoqZ3r9a, IP: 42.105.49.112, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:24:00,511 - Client ID: mosq-CarDIXUElooXBFwUWv, IP: 42.105.49.112, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:24:00,516 - Client ID: mosq-27NvXOSVWtkATHvRND, IP: 42.105.49.112, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:24:35,960 - Client ID: TERM2, IP: 49.205.128.126, Clean Start: true, Session Expiry: 0 connected.
2022-05-05 13:25:12,950 - Client ID: mosq-S5S8DJc0pdf6gnxu94 session has expired at 2022-05-05 13:10:20. All persistent data for this client has been removed.
2022-05-05 13:26:05,292 - Client ID: TERM2, IP: 49.205.128.126 disconnected gracefully.

Is the reason the ls command shows no client is that all the publish clients are only connected momentarily and are all disconnected now? Well even if this is true why are the sub clients missing? I receive data every minute successfully so the clients are all connected.

Thanks for going through this post and trying to help.

Best

Hi @sanjmeh,

I assume you talk about the “ls” feature of the mqtt-cli? This only lists clients connected via the mqtt-cli.

There is another feature of the mqtt-cli: mqtt hivemq export clients, that could help you but this works only with the HiveMQ EE version as you need the Rest API feature (see mqtt-cli docs).

Greetings,
Michael from the HiveMQ team

1 Like

Thank you @michael_w . Yes I was trying the ls feature of mqtt-cli. And this is the first shock I get after switching from hivemq-ee to hivemq-ce. I was told to try hivemq-ce as it can go very well upto 1000 clients before we can switch to the expensive hivemq-ee. Now with this limitation of ls not showing all connections, what are the work arounds you suggest? One thing that comes to my mind is writing a script to process the event.log file to simulate the ls command. For me ls is essential because there is no console we have like in hive-mq ee. I do need a way to check connections.

You can either write the script to process the event.log or you create your own extension that exposes an REST endpoint for getting information about all clients.
When this rest endpoint is called you can use the extension system to iterate over all clients, collect the clients in a list (or whatever collection) and then send the list in the response of the rest call.

Alternatively, you leave out the REST service and just write the client information into a local file or somewhere else (even to remote service if wanted).

1 Like

Thanks. I am lookng into your options.

Managed to publish the event.log file on to a public directory (/var/www/html) to expose it to on the apache server’s public dir. Now it is downloadable.

Next am looking to write a small R script that creates a summary of the last 100 lines and stores in another smaller file that will be faster to download every minute.