-
Notifications
You must be signed in to change notification settings - Fork 4
Why is the ClientId important?
A ClientId does not seem that important, but it is in fact very important in order for the broker to distinguish to whom resend a PUBLISH packet in case of any issues, specially in situations where a QoS level greater than 0 is used. More information about QoS levels.
The ClientId must be as unique as possible: if the broker sends a QoS level 2 message and the client does respond partially or not at all due to for example a network issue, when reconnecting the broker can decide to send the message that failed previously again so that the Client can process it anyway.
So the rule of thumb with a ClientId is: always use a unique one for each process. If that process crashes or has network problems, reconnect with the same ClientId in order to be able to re-process possible missing PUBLISH packets.