Skip to content

SSE Server drops client connection at 5 min. #414

@albayrakonur

Description

@albayrakonur

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions