No limits for MQTT clients identifiers

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

author HiveMQ Team

Written by HiveMQ Team

Category: MQTT MQTT Client

Published: September 10, 2013

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 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.

author HiveMQ Team

About HiveMQ Team

We love writing about MQTT, IoT protocols and architecture in general. Our experts are here to help, so reach out to us if we can help!

mail icon Contact HiveMQ
newer posts HiveMQ: MQTT in the Microsoft Cloud on Windows Azure
HiveMQ - MQTT over Websockets older posts