Inspecting and managing sessions
Inspecting and managing MQTT sessions
Inspecting sessions
VerneMQ comes with powerful tools for inspecting the state of MQTT sessions. To list current MQTT sessions simply invoke vmq-admin session show
:
To see detailed information about the command see vmq-admin session show --help
.
The command is able to show a lot of different information about a client, for example the client id, the peer host and port if the client is online or offline and much more, see vmq-admin session show --help
for details. Further the information can also be used to filter information which is very helpful when wanting to narrow down the information to a single client.
A sample query which lists only the node where the client session exists and if the client is online would look like the following:
Note, by default a maximum of 100 rows are returned from each node in the cluster. This is a mechanism to protect the cluster from overload as there can be millions of MQTT sessions and resulting rows. Use --limit=<RowLimit>
to override the default value.
More examples
Listing the clients and the subscriptions one can do the following:
And to list only the clients subscribed to the topic some/topic
:
To figure out when the queue for a persisted session (clean_session=false) was created and when the client last connected one can use the --queue_started_at
and --session_started_at
to list the POSIX timestamps (in microseconds):
Besides the examples above it is also possible to inspect the number of online or offline messages as well as their payloads and much more. See vmq-admin session show --help
for an exhaustive list of all the available options.
Managing sessions
VerneMQ also supports disconnecting clients and reauthorizing client subscriptions. To disconnect a client and cleanup store messages and remove subscriptions one can invoke:
See vmq-admin session disconnect --help
for more options and details.
To reauthorize subscriptions for a client issue the following command:
This works by reapplying the logic in any installed auth_on_subscribe
or auth_on_subscribe_m5
plugin hooks to check the validity of the existing topics and removing those that are no longer allowed. In the example above the reauthorization of the client subscriptions resulted in no changes.
Last updated