-
Notifications
You must be signed in to change notification settings - Fork 571
Sends a heartbeat (ping) to all connected clients to keep connection… #353
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
…s alive. This method sends ping notifications to all active sessions without expecting a response, which helps prevent connection timeouts. @return A Mono that completes when heartbeat has been sent to all sessions
Sends a heartbeat (ping) to all connected clients to keep connections alive. This method sends ping notifications to all active sessions without expecting a response, which helps prevent connection timeouts. |
@FrolikovEA can you elaborate on this? What connection timeouts do you see. |
Good afternoon @tzolov
|
I am wondering if it wasn't easier if we exposed Why in the Mcp*Server instead of transport? Because it's a domain level method meant for heartbeat and the domain level methods are there and also in |
TODO: PING is a Temporary solution: @FrolikovEA could you try using the existing McpAsyncServer#loggingNotification and McpSyncServer#loggingNotification methods that already broadcast to all connected clients? Still PING's advantage might be its silent acknowledgment with empty responses, providing bidirectional communication validation. Alternative: In system-design to setup a heart-beat, one would use HTTP keep-alive configuration with an HTTP proxy server for production MCP deployments - likely the standard cloud setup anyway. |
* response, which helps prevent connection timeouts. | ||
* @return A Mono that completes when heartbeat has been sent to all sessions | ||
*/ | ||
public Mono<Void> sendHeartbeat() { |
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.
we need a configuration to do the scheduling of sending
Resolves: modelcontextprotocol#414, modelcontextprotocol#158 Replaces modelcontextprotocol#353 Signed-off-by: Christian Tzolov <[email protected]>
Resolves: modelcontextprotocol#414, modelcontextprotocol#158 Replaces modelcontextprotocol#353 Signed-off-by: Christian Tzolov <[email protected]>
…nsports - Add KeepAliveScheduler utility class for configurable periodic session pings - Integrate keep-alive support in WebFlux, WebMVC, and HttpServlet SSE transport providers - Add keepAliveInterval configuration option to all transport provider builders - Deprecate existing constructors in favor of builder pattern with enhanced configuration - Update graceful shutdown to properly clean up keep-alive schedulers - Add unit tests for KeepAliveScheduler functionality Implements MCP specification recommendations for connection health detection: - Configurable ping frequency to suit different network environments - Optional keep-alive (disabled by default) to avoid excessive network overhead - Proper resource cleanup to prevent connection leaks https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/ping#implementation-considerations Resolves: modelcontextprotocol#414, modelcontextprotocol#158 Replaces modelcontextprotocol#353 Signed-off-by: Christian Tzolov <[email protected]>
…nsports - Add KeepAliveScheduler utility class for configurable periodic session pings - Integrate keep-alive support in WebFlux, WebMVC, and HttpServlet SSE transport providers - Add keepAliveInterval configuration option to all transport provider builders - Deprecate existing constructors in favor of builder pattern with enhanced configuration - Update graceful shutdown to properly clean up keep-alive schedulers - Add unit tests for KeepAliveScheduler functionality Implements MCP specification recommendations for connection health detection: - Configurable ping frequency to suit different network environments - Optional keep-alive (disabled by default) to avoid excessive network overhead - Proper resource cleanup to prevent connection leaks https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/ping#implementation-considerations Resolves: #414, #158 Replaces #353 Signed-off-by: Christian Tzolov <[email protected]>
Resolved by #430 |
…s alive. This method sends ping notifications to all active sessions without expecting a response, which helps prevent connection timeouts.
@return A Mono that completes when heartbeat has been sent to all sessions
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context