Commit 5c47844
Move markInitialized/reconnect after status code check in Streamable HTTP transport
When the server returns a non-2xx status code (e.g. 405 Method Not Allowed),
markInitialized() and reconnect() were called before the status code was
checked. This caused an unnecessary GET request, which is problematic when
using transport fallback (Streamable HTTP -> SSE) as it creates duplicate
SSE sessions on the server.
Move markInitialized() and reconnect() inside the 2xx success branch so
they are only called when the server actually accepted the connection.
Fixes #773
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 26304a7 commit 5c47844
File tree
1 file changed
+9
-8
lines changed- mcp-core/src/main/java/io/modelcontextprotocol/client/transport
1 file changed
+9
-8
lines changedLines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | 481 | | |
490 | 482 | | |
491 | 483 | | |
492 | 484 | | |
493 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
494 | 495 | | |
495 | 496 | | |
496 | 497 | | |
| |||
0 commit comments