diff --git a/mcp/src/main/java/org/springframework/ai/mcp/client/transport/FlowSseClient.java b/mcp/src/main/java/org/springframework/ai/mcp/client/transport/FlowSseClient.java index 3fa932a..4b6191d 100644 --- a/mcp/src/main/java/org/springframework/ai/mcp/client/transport/FlowSseClient.java +++ b/mcp/src/main/java/org/springframework/ai/mcp/client/transport/FlowSseClient.java @@ -198,8 +198,9 @@ public class FlowSseClient { info -> subscriberFactory.apply(lineSubscriber)); future.thenAccept(response -> { - if (response.statusCode() != 200) { - throw new RuntimeException("Failed to connect to SSE stream: " + response.statusCode()); + int status = response.statusCode(); + if (status != 200 && status != 201 && status != 202 && status != 206) { + throw new RuntimeException("Failed to connect to SSE stream. Unexpected status code: " + status); } }).exceptionally(throwable -> { eventHandler.onError(throwable); @@ -207,30 +208,4 @@ public class FlowSseClient { }); } - // public static void main(String[] args) { - - // FlowSseClient sseClient = new FlowSseClient( - // HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build()); - - // var eventHandler = new SSEEventHandler() { - // @Override - // public void onEvent(SSEEvent event) { - // System.out.println("Received event: " + event); - // } - - // @Override - // public void onError(Throwable error) { - // System.out.println("Error: " + error); - // } - // }; - // sseClient.subscribe("http://localhost:8080/sse", eventHandler); - - // try { - // Thread.sleep(100000); - // } - // catch (InterruptedException e) { - // e.printStackTrace(); - // } - // } - }