-
Notifications
You must be signed in to change notification settings - Fork 271
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
feat(pubsub): Implement Ping/Pong Mechanism to Improve Connection Reliability #3845
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @0xIchigo, this seems pretty close. I have a couple small comments, and we'll have to see how CI fares.
(edit) For starters, CI is complaining about trailing whitespace that needs to be removed.
While you're making updates, can you please rebase on master to remove all the merge commits and force-push?
021171c
to
6b00e49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to run CI on this yet, as I can see it will not compile. Please fix compilation errors, thanks.
6fd9c76
to
f05a77d
Compare
Code does not compile; see CI. |
910db8e
to
f68a307
Compare
My apologies @CriesofCarrots, I was able to fix all my build issues and run the code locally. All the compile errors should be fixed now! |
Problem
Both the blocking and nonblocking
PubsubClient
clients currently lack a mechanism to detect when the WebSocket connection becomes unresponsive or stale. Without periodic health checks, the clients may not realize that the server is no longer responding. This can lead to missed messages and unreliable subscriptions. This can affect applications relying on WebSockets to provide real-time data streamsSummary of Changes
This PR aims to implement a ping/pong mechanism in both the blocking and nonblocking
PubsubClient
clients to improve connection reliabilityChanges
Ping
message sent to the server usingtokio::time::interval
Pong
messages and reset theunmatched_pings
counter upon receiving any messageunmatched_pings
counter exceedsDEFAULT_MAX_FAILED_PINGS
DEFAULT_PING_DURATION_SECONDS
andDEFAULT_MAX_FAILED_PINGS
, as making them configurable would've meant changing the existing subscription parameters resulting in a breaking change. However, these params could easily be changed in the future to become configurable—the importance here is introducing reliable health checks to WebSocket connections