adafruit / Adafruit_CircuitPython_MiniMQTT

MQTT Client Library for CircuitPython
Other
73 stars 50 forks source link

exponential backoff for (re)connect #151

Closed vladak closed 1 year ago

vladak commented 1 year ago

This change implements exponential back-off for connect/reconnect based on the Google IoT algorithm description (sic!), with a nuance in handling temporary errors (like name resolution errors or memory shortage). At one point I had code that applied the exponential back-off also for successfull reconnect()s, however found it a bit too complex and hand-holdy. If one calls reconnect() in a loop even after prior successful connect without sleeping in between, he probably deserves to be rate limited by the broker.