Client identifier

The client identifier is a 23 byte string that identifies an MQTT client. Each identifier must be unique to only one connected client at a time. The identifier must contain only characters valid in a queue manager name. Within these constraints, you are able to use any identification string. It is important to have a procedure for allocating client identifiers, and a means of configuring a client with its chosen identifier.

The client identifier is used in the administration of an MQTT system. With potentially hundreds of thousands of clients to administer, you need to be able to identify a particular client rapidly. For example, suppose a device has malfunctioned and you are notified, perhaps by a customer ringing a help desk. The customer needs to be able to identify the device, and you need to be able to correlate that identification with the server that is typically connected to the client.

When you browse through MQTT client connections, each connection is labeled with the client identifier. To help decide how best to map this identifier to the device and server, ask yourself the following questions:

  • Would it be convenient to maintain and use a database that maps each device to a client identifier and to a server?
  • Could the name of the device identify the server to which it is attached?
  • Do you need a look-up table that maps a client identifier to a physical device?
  • Does the client identifier identify a particular device, a user, or an application running at the client?
  • If a customer replaces a faulty device with a new one, does the new device have the same identifier as the old device, or do you allocate a new identifier? (If you change a physical device and keep the same identifier, outstanding publications and active subscriptions are automatically transferred to the new device.)

You also need a system to ensure that client identifiers are unique, and you must have a reliable process for setting the identifier on the client. If the client device is a "black-box", with no user interface, you could manufacture the device with a client identifier, or you could have a software installation and configuration process that configures the device before it is activated.

To keep the identifier short and unique, you could create a client identifier from the 48 bit device MAC address. If transmission size is not a critical issue, you could then use the remaining 17 bytes to make the address easier to administer.