fbradyirl / webex_bot

Python package for a Webex Bot based on websockets.
MIT License
68 stars 44 forks source link

Add web socket Max backoff time #55

Closed fbradyirl closed 4 months ago

fbradyirl commented 4 months ago

The backoff.expo decorator provides "exponential backoff". This design pattern is common in connection recovery scenarios where multiple or continuous connection attempts might be penalized with temporary or permanent bans, or it might simply be a waste of resources when connection is not possible due to network conditions. By using an exponential backoff algorithm, each subsequent attempt waits for a longer delay between retries, thus reducing load and respecting policies.

However, we didnt have a maximum backoff time is specified. The calculation for the backoff time is (factor * (2 ** (num_retries - 1))) (num_retries gets incremented after each fail), where "factor" takes default value 1 second. After a number of failures, the delay between retries can become very long.