As stated on this page, the Eclipse Paho Python client provides a buffer for messages not sent when the client is offline, these messages are finally sent when the client reconnects to the broker.
Is there a way to disable this feature to prevent server flooding when a large number of clients reconnects at the same time ?
reinitialise() method will clear stored messages.
From the doc here
a boolean that determines the client type. If True, the broker will remove all information about this client when it disconnects. If
False, the client is a durable client and subscription information and queued messages will be retained when the client disconnects.
Note that a client will never discard its own outgoing messages on disconnect. Calling connect() or reconnect() will cause the messages to be resent. Use reinitialise() to reset a client to its original state.
Documentation for reinitialise is here:
reinitialise(client_id="", clean_session=True, userdata=None)
The reinitialise() function resets the client to its starting state as if it had just been created. It takes the same arguments as the Client() constructor. Example
You can set this up to be called in the
on_disconnect call back.