Skip to content

MCPServer Redeployment causes this behavior "Error sending message: 404" in MCPClient #2785

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

Open
dilipsundarraj1 opened this issue Apr 17, 2025 · 2 comments

Comments

@dilipsundarraj1
Copy link

Bug Report

Bug description

I have a MCP Server and the MCP client built. First, I spin up the MCP Server and then the MCP client. My client app interacts with the MCP server and works fine.
However, when I restart or redeploy the MCP Server, the client app interacts with the MCP server, and I observe the following error:

2025-04-17T11:02:40.637-05:00 ERROR 14929 --- [onPool-worker-3] i.m.c.t.HttpClientSseClientTransport : Error sending message: 404 

Detailed Error

2025-04-17T11:02:39.088-05:00 INFO 14929 --- [nio-8086-exec-4] com.llm.controller.ChatsController : userInput message : UserInput(prompt=Find me all the phones ?) 2025-04-17T11:02:39.088-05:00 INFO 14929 --- [nio-8086-exec-4]  

com.llm.controller.ChatsController : requestSpec : org.springframework.ai.chat.client.DefaultChatClient$DefaultChatClientRequestSpec@2f15ab7e 2025-04-17T11:02:39.088-05:00 INFO 14929 --- [nio-8086-exec-4] com.llm.controller.ChatsController : responseSpec1 : org.springframework.ai.chat.client.DefaultChatClient$DefaultCallResponseSpec@21d250ec 2025-04-17T11:02:40.132-05:00 DEBUG 14929 --- [nio-8086-exec-4] o.s.a.m.tool.DefaultToolCallingManager : Executing tool call: spring_ai_mcp_client_person_mcp_server_getAllProducts 

2025-04-17T11:02:40.637-05:00 ERROR 14929 --- [onPool-worker-3] i.m.c.t.HttpClientSseClientTransport : Error sending message: 404 

2025-04-17T11:06:40.155-05:00 ERROR 14929 --- [nio-8086-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: reactor.core.Exceptions$ReactiveException: java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 240000ms in 'source(MonoCreate)' (and no fallback has been configured)] with root cause


Environment

  • Spring AI version: 1.0.0-M7
  • Java version: 21
  • Vector Store: [Provide details if used, or leave blank]

Steps to reproduce

  1. Spin up the MCP Server.
  2. Spin up the MCP client and interact with the MCP Server (this works fine).
  3. Restart or redeploy the MCP Server.
  4. Have the MCP client interact with the MCP server again.
  5. Observe the error.

Expected behavior

I expected the MCP client to interact with the MCP server successfully after the server restart, without any errors.

Minimal Complete Reproducible example

You can view the complete example in my GitHub repository.

@yangtuooc
Copy link
Contributor

After the server restarts, it loses all session states, but the client is still using its old session ID. This causes ‘session not found’ errors.
Here is the relevant code snippet from the source:

private final ConcurrentHashMap<String, McpServerSession> sessions = new ConcurrentHashMap<>();
// ...
private ServerResponse handleMessage(ServerRequest request) {
    // ...
    String sessionId = request.param("sessionId").get();
    McpServerSession session = sessions.get(sessionId);

    if (session == null) {
        return ServerResponse.status(HttpStatus.NOT_FOUND).body(new McpError("Session not found: " + sessionId));
    }
    // ...
}

Source: WebMvcSseServerTransportProvider.java

@dilipsundarraj1
Copy link
Author

@yangtuooc Yep I also noticed the same thing.
The reason for creating this issue is to bring it to everyone's attention. Ideally I would expect the server to enable the new connection using the passed in id or create a brand new connection .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants