Skip to content Skip to sidebar Skip to footer

Mosquitto Unexpected Disconnection

I am using python mosquitto(paho) library. I got the problem of Unexpected disconnection. I found constantly dropping and connection with the server. . I am unable to find the prob

Solution 1:

You have multiple connections using the same client_id. client_id's have to be unique, the broker will only allow one connection with a client_id at a time and will kick the oldest one off the broker when a new connection is formed. If you have reconnection logic in place then the old client will try and reconnect which will kick the new client off, this ends up in a feed back look with no client managing to stay connected to the broker.

It looks like you have hard coded your client_id to "publisher" from the logs, this needs to be changed to be a unique value, normally I would set a to a prefix like "pub_" then add on a random number, a timestamp or some other identifier (e.g. thead number/name)

Post a Comment for "Mosquitto Unexpected Disconnection"