spring-projects / spring-projects/spring-ai
SSE Server drops client connection at 5 min.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
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 @tzolov suggested a solution but does spring ai support this not sure.
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Spring AI example linked in the issue and its /sse endpoint, then reproduce the five-minute disconnect using the supplied client setup and logs. Review the linked MCP SDK discussion for the suggested keep-alive approach. Done means SSE clients remain connected beyond the timeout through configurable periodic server-side pings, with the relevant behavior verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100