Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reconnect exponential backoff #990

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

soerenbe
Copy link

@soerenbe soerenbe commented Jun 5, 2024

Like discussed in #989 here the MR for the support for the exponential backoff reconnect delay.

As discussed this adds the additional parameter reconnect_backoff_max to WebSocketApp.run_forever

I was not 100% sure where to place the calculation of the reconnect timer, since it it should be called from the normal run_server loop and also from the custom dispatcher. I saw 2 possible implementations: A method for the WebSocketApp class or a function inside the run_forever method.

I chose to implement a simple method for the WebSocketApp class. There I could store the retry counter. Passing the retry parameters was ok for me. But overall this functions definitions inside the run_forever method felt a little strange.

Some random notes:

  • If the value reconnect_backoff_max is smaller than the original reconnect timer, the value of reconnect_backoff_max will be used as reconnect time, but there will be also a warning message.
  • I have added a documentation chapter about the reconnect behavior. This also includes a short description of the already existing reconnect parameter
  • I added some basic tests for the calculation method. If you think there should be some end-to-end test, it would be nice If can give me some hints, because this tests with a running ws server looked a little confusing and hard to setup to me.

Looking forward to your feedback!
Sören

@soerenbe soerenbe changed the title Add upport for reconnect exponential backoff Add support for reconnect exponential backoff Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant