Skip to content

No limits: MQTT clients identifiers can have more than 23 characters

by HiveMQ Team
3 min read

Historically, the MQTT client identifier in the CONNECT message is restricted to 23 characters in the MQTT v3.1 specification. Unfortunately there are many use cases where this artificial restriction is a burden for implementors on the client side, because many people would like to use longer client identifier, especially when they are randomly generated (An example would be using UUIDs as identifiers).

HiveMQ implements the MQTT v3.1 specification thoroughly and so this artificial limit of client identifiers with a maximum length of 23 characters was also used. Version 1.4 of HiveMQ now has support for client identifiers longer than 23 characters. In fact, the technically restricted maximum length of a client id can be 65535 characters. It is now even possible - although for most scenarios only partly useful - to limit the client id characters to a lower number.

By default, HiveMQ uses the standard MQTT limit of 23 characters to assure MQTT specification compatibility. If you are sure you want to change this behaviour, change the property global.maxClientIdLength in the configuration.properties file of your HiveMQ installation to a number you like to use.

When using higher limits, please make sure that your MQTT library also supports longer client identifiers. Unfortunately the Java and Javascript version of Eclipse Paho enforces a maximum client id length of 23, so you probably need to use another MQTT library if you need longer client identifiers for your scenario.

Do you think this feature is useful? Did you have any problems with too long client ids before? We’d love to hear from you in the comments!

Update: Thanks to Roger Light who clarified that only the Java and Javascript Paho clients prohibit using client identifiers > 23 characters.

HiveMQ Team

The HiveMQ team loves writing about MQTT, Sparkplug, Industrial IoT, protocols, how to deploy our platform, and more. We focus on industries ranging from energy, to transportation and logistics, to automotive manufacturing. Our experts are here to help, contact us with any questions.

HiveMQ logo
Review HiveMQ on G2