-
Notifications
You must be signed in to change notification settings - Fork 111
fix: add a ping loop for http transport clients #484
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
Conversation
48207f3
to
f54b86f
Compare
src/transports/streamableHttp.ts
Outdated
|
||
if (++failedPings > 3) { | ||
clearInterval(keepAliveLoop); | ||
await transport.close(); |
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.
This needs to be in a try-catch
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.
Gucci
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.
Pull Request Overview
This PR implements a heartbeat mechanism for HTTP transport clients by adding a ping loop that sends periodic pings every 30 seconds to maintain connection liveness. The implementation closes the transport after 3 consecutive failed ping attempts.
- Adds ping loop functionality with 30-second intervals and failure tracking
- Introduces new log IDs for ping operations and failures
- Updates error message formatting and logging for better debugging
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/transports/streamableHttp.ts | Implements the main ping loop logic with keepalive interval and transport closure after failed pings |
src/index.ts | Enhances error logging in server close handler with error details |
src/common/logger.ts | Adds new log IDs for ping operations and failures |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Proposed changes
This makes it so the server sends a ping every 30 seconds to connected clients to ensure the connection is still alive. After 3 failed pings, we close the transport.
Checklist