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

reconnect should fall back gracefully #16

Open
ConfusedVorlon opened this issue Apr 24, 2023 · 3 comments
Open

reconnect should fall back gracefully #16

ConfusedVorlon opened this issue Apr 24, 2023 · 3 comments

Comments

@ConfusedVorlon
Copy link

I love how robust the reconnection is, however if connections fail repeatedly, then the default of attempting every 0.5 seconds is going to hammer a struggling server.

If the reason that the connection is failing is a server in trouble, then this potentially adds something close to a denial of service attack on top of whatever problem exists...

Standard practice would be an exponential fallback - so, waiting (twice?, 1.5x?) as long between each reconnection attempt.
Perhaps to a maximum of a 60 second delay between checks...

I'm happy to have a go if you'd accept a pull request...

@nerzh
Copy link
Owner

nerzh commented Apr 25, 2023

I'll be glad to accept your pull request, but please make the reconnect parameter data type enum instead of boolean. Let the enum contain three cases: none, standard, and your reconnect case

@ConfusedVorlon
Copy link
Author

will do.

Before I get stuck in - could you explain a bit around the locking in PingWatcher ?

I understand the locking around finish - this is accessed from the public isFinish() function, and also from the watcher thread.

Other variables like lastTimePoint seem to be only accessed from the watcher thread (and are private).

Is this just a case of being overly cautious, or am I missing some subtlety?

@nerzh
Copy link
Owner

nerzh commented Apr 25, 2023

This library was made very quickly for my project, it still works there. I want to say that there was no goal to make a library. I realized that it might be useful to others, so I made it public. This means that I wrote the code a long time ago and there may be inaccuracies. Just make your code work, you can rewrite my watcher if needed

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

No branches or pull requests

2 participants