If you encounter this duplicate error message "POINT_PERFECT_DUPLICATE_CONNECT_ERROR_EVENT Duplicate clientId used for Point Perfect device device:bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
this indicates that the MQTT broker has received a connection request from a client identifier (Client ID) that is already associated with an active connection. According to the MQTT protocol, each client can only have one active connection per Client ID. When a new connection request is received with a duplicate Client ID, the broker will terminate the existing session and establish a new one for the latest client.
To avoid this error, there are a few methods to ensure proper disconnection of the device from the MQTT session. Configure the MQTT Client based on your specific requirements. Examples are in Python using the paho-mqtt library.
1. Proper Disconnection Before Powering Off: Ensure your device explicitly sends a `DISCONNECT` message to the MQTT broker before shutting down. Add a disconnect function in your device’s code to run before power-off.
client.disconnect()
2. Configuring Session Expiration: Set a reasonable `keepalive` interval (e.g., 60 seconds) in your MQTT connection settings. This ensures the session expires if the client doesn’t reconnect in time. PointPerfect's frequent updates will automatically refresh the session during normal operation.
client.connect("pp.services.u-blox.com", 8883, keepalive=60)
3. Using Clean Session: Set the `clean session` option to `True` when connecting. This discards any previous session and ensures the broker starts a new session with each connection, preventing issues with leftover sessions from earlier connections.
client.connect("pp.services.u-blox.com", 8883, clean_session=True)