In MQTT it is the client who initiates the connection with a CONNECT message.
The first field of the packet is the
The client identifier (short ClientId) is an identifier of each MQTT client connecting to a MQTT broker. As the word identifier already suggests, it should be unique per broker. The broker uses it for identifying the client and the current state of the client. (Image and quote are taken from from here.)
Now let's say I have two clients, client X and Y in the following situation.
- Broker launched, no clients yet.
- X succesfully connects to the broker with
client-1id, username is
- Now, Y tries to connect using
client-1as id, username is
What will happen?
- Based on the clientId, the broker will think that X performs a repeated connection attempt which is abnormal behavior.
- Nothing extraordinary will happen. Y connects successfully as it uses a different username.
- Nothing extraordinary will happen. The broker will reject Y connection attempt as the given clientId is already in use.