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 ping-pong implementation that handles stale connections. #239

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

domenkozar
Copy link
Collaborator

@domenkozar domenkozar commented Dec 23, 2023

Because the Server used only pong implementation it's not possible to keep backwards compatibility with the new implementation that also does pinging.

Fixes #159

cc @jaspervdj

@domenkozar domenkozar changed the title Implement ping-pong implementation that handles state connections. Implement ping-pong implementation that handles stale connections. Dec 23, 2023
@domenkozar domenkozar force-pushed the ping-pong branch 2 times, most recently from f22f55e to 242fa79 Compare December 23, 2023 18:36
@domenkozar domenkozar changed the title Implement ping-pong implementation that handles stale connections. Add ping-pong implementation that handles stale connections. Dec 23, 2023
Copy link
Owner

@jaspervdj jaspervdj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great, I like how we can use the same code for client & server. I left two minor comments but they're not really blockers.

@@ -252,6 +255,7 @@ data Connection = Connection
{ connectionOptions :: !ConnectionOptions
, connectionType :: !ConnectionType
, connectionProtocol :: !Protocol
, connectionHeartbeat :: !(MVar ())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a comment to the field explaining how this is used (or refer to the PingPong module).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

-- for example N/2.
data PingPongOptions = PingPongOptions {
pingInterval :: Int, -- ^ Interval in seconds
pongTimeout :: Int, -- ^ Timeout in seconds
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only noticed this because of the comment on the other PR; but I guess it would be more consistent if the library uses microseconds for time everywhere rather than mixed units?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the other Ping utilities use seconds, maybe it's better we just use seconds for the connection timeout as well. I'll add it to the other PR.

Because the Server used only pong implementation it's not possible
to keep backwards compatibility with the new implementation that
also does pinging.
@domenkozar domenkozar merged commit 680a5e0 into jaspervdj:master Dec 27, 2023
7 checks passed
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.

How to do application-level ping timeout properly?
2 participants