roskakori
roskakori

Reputation: 3336

How to handle multiple clients with same ID in mosquitto MQTT?

How can I tell mosquitto MQTT what to do in case multiple persistent subscribers attempt to connect with the same client ID?

I accidentally ran into this situation when misconfiguring different testing environments which subscribed to the same broker. The result was that both subscribers got only part of the messages and the mosquitto log was spammed with "New connection from xxx" messages. Preferably the second subscriber would be rejected to make such a mistake apparent immediately.

I found a similar question for Solace and it seems to offer the option to either replace the older subscriber with the new one or reject the new one.

However when checking the available options for mosquitto.conf I could not see a similar option.

Upvotes: 1

Views: 8353

Answers (1)

hardillb
hardillb

Reputation: 59608

You don't.

The MQTT Spec says that client ids have to be unique and the correct behaviour is to kick the oldest one off and replace it with the new one.

Upvotes: 12

Related Questions