Repository navigation
SSE Server drops client connection at 5 min. #414
Description
Activity
- changed the title
[-]SSE Server drop client connection at 5 min.[/-][+]SSE Server drops client connection at 5 min.[/+]on Jul 18, 2025 Related to #353
@albayrakonur, please check this comment.
In the meantime please consider using the McpAsyncServer#loggingNotification and McpSyncServer#loggingNotification for the same purpose heatbeating- added 3 commits that reference this issue
on Jul 30, 2025 - added a commit that references this issue
on Jul 30, 2025 I tried it locally, but it seems that the issue has not been resolved. Below is the log I reproduced
1. client init success
client
2025-08-06 18:36:09.556 DEBUG [TID: N/A] [HttpClient-1-Worker-0] io.modelcontextprotocol.spec.McpSchema - Received JSON message: {"jsonrpc":"2.0","id":"a2ab5686-0","result":{"protocolVersion":"2024-11-05","capabilities":{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"subscribe":false,"listChanged":true},"tools":{"listChanged":true}},"serverInfo":{"name":"action-server","version":"1.0.0"}}}
server2025-08-06 18:36:09.553 DEBUG [TID: N/A] [http-nio-8080-exec-4] io.modelcontextprotocol.spec.McpServerSession - Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=a2ab5686-0, params={protocolVersion=2024-11-05, capabilities={}, clientInfo={name=Spring AI MCP Client, version=0.3.1}}]
2. client send ping/5s
client log
2025-08-06 18:36:10.152 DEBUG [TID: N/A] [pool-12-thread-1] io.modelcontextprotocol.spec.McpClientSession - Sending message for method ping 2025-08-06 18:36:10.155 DEBUG [TID: N/A] [HttpClient-1-Worker-0] io.modelcontextprotocol.spec.McpSchema - Received JSON message: {"jsonrpc":"2.0","id":"a2ab5686-1","result":{}}
3. server send ping/30s
client log
2025-08-06 18:36:13.536 DEBUG [TID: N/A] [HttpClient-1-Worker-3] io.modelcontextprotocol.spec.McpSchema - Received JSON message: {"jsonrpc":"2.0","method":"ping","id":"c5a37778-c744-4a5e-9108-75be2fe5fb89-0"} 2025-08-06 18:36:13.537 DEBUG [TID: N/A] [HttpClient-1-Worker-3] io.modelcontextprotocol.spec.McpClientSession - Received request: JSONRPCRequest[jsonrpc=2.0, method=ping, id=c5a37778-c744-4a5e-9108-75be2fe5fb89-0, params=null] 2025-08-06 18:36:13.539 DEBUG [TID: N/A] [HttpClient-1-Worker-3] io.modelcontextprotocol.client.McpAsyncClient - Received ping: 2025-08-06T18:36:13.5388951
4. After about 5 minutes
ping timeout , try next init
2025-08-06 18:40:36.793 DEBUG [TID: N/A] [pool-12-thread-1] io.modelcontextprotocol.spec.McpClientSession - Sending message for method initialize 2025-08-06 18:40:36.803 DEBUG [TID: N/A] [HttpClient-2-Worker-2] io.modelcontextprotocol.spec.McpSchema - Received JSON message: {"jsonrpc":"2.0","id":"20fb107a-0","result":{"protocolVersion":"2024-11-05","capabilities":{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"subscribe":false,"listChanged":true},"tools":{"listChanged":true}},"serverInfo":{"name":"action-server","version":"1.0.0"}}}A new discovery has been made: after the client initiates around 60 pings, subsequent requests will encounter issues. During this period, no other messages are sent to the server; only ping operations are performed
- added a commit that references this issue
on Jun 25, 2026
Bug description
I developed a MCP server with webmvc SSE endpoint but when a client connects via /sse endpoint, after appx 5 min later server drops connection. This is happen because Client-side needs from server-side to ping itself. Current release doesnt support this and
Environment
JDK:17
Spring Boot: 3.5.3
Spring AI: 1.0.0
Steps to reproduce
You can reproduce this bug on any setup. I try with Spring example with webmvc https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webmvc-server You can start this app and just connect it with cursor or vscode and then 5min later client will got an error.
Client-side servername: LOCAL-SERVER,
"LOCAL-SERVER": {
"url": "http://localhost:8080/sse"
}
2025-07-18 21:18:05.422 [info] user-LOCAL-SERVER: Handling CreateClient action
2025-07-18 21:18:05.422 [info] user-LOCAL-SERVER: Creating streamableHttp transport
2025-07-18 21:18:05.422 [info] user-LOCAL-SERVER: Connecting to streamableHttp server
2025-07-18 21:18:05.432 [error] user-LOCAL-SERVER: Client error for command Error POSTing to endpoint (HTTP 404): {"timestamp":"2025-07-18T18:18:05.431+00:00","status":404,"error":"Not Found","path":"/sse"}
2025-07-18 21:18:05.433 [info] user-LOCAL-SERVER: Client closed for command
2025-07-18 21:18:05.433 [error] user-LOCAL-SERVER: Error connecting to streamableHttp server, falling back to SSE: Error POSTing to endpoint (HTTP 404): {"timestamp":"2025-07-18T18:18:05.431+00:00","status":404,"error":"Not Found","path":"/sse"}
2025-07-18 21:18:05.433 [error] user-LOCAL-SERVER: Error connecting to streamableHttp server, falling back to SSE: Error POSTing to endpoint (HTTP 404): {"timestamp":"2025-07-18T18:18:05.431+00:00","status":404,"error":"Not Found","path":"/sse"}
2025-07-18 21:18:05.433 [info] user-LOCAL-SERVER: Connecting to SSE server
2025-07-18 21:18:05.448 [info] user-LOCAL-SERVER: Successfully connected to streamableHttp server
2025-07-18 21:18:05.448 [info] user-LOCAL-SERVER: Storing streamableHttp client
2025-07-18 21:18:05.449 [info] user-LOCAL-SERVER: Handling ListOfferings action
2025-07-18 21:18:05.449 [info] user-LOCAL-SERVER: Listing offerings
2025-07-18 21:18:05.449 [info] user-LOCAL-SERVER: Connected to streamableHttp server, fetching offerings
2025-07-18 21:18:05.452 [info] listOfferings: Found 3 tools
2025-07-18 21:18:05.452 [info] user-LOCAL-SERVER: Found 3 tools
2025-07-18 21:23:09.107 [error] user-LOCAL-SERVER: Client error for command SSE error: TypeError: terminated: Body Timeout Error
Expected behavior
You can add periodic ping option to keep alive for each client connection. (time)
Same issue: https://github.com/modelcontextprotocol/typescript-sdk/issues/270