Skip to content

[Client] Resume interrupted SSE streams - #463

Open
wWzZb wants to merge 1 commit into
modelcontextprotocol:mainfrom
wWzZb:agent/issue-327-sse-reconnect
Open

[Client] Resume interrupted SSE streams#463
wWzZb wants to merge 1 commit into
modelcontextprotocol:mainfrom
wWzZb:agent/issue-327-sse-reconnect

Conversation

@wWzZb

@wWzZb wWzZb commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

The bug

When an SSE response ended before its JSON-RPC response arrived, HttpTransport discarded the stream. It did not retain the SSE id or retry fields, so the pending request waited for its timeout instead of resuming from the last event.

The fix

  • Track the latest SSE event ID and the server-provided retry interval.
  • Resume interrupted streams with a GET carrying Accept: text/event-stream, Mcp-Session-Id, and Last-Event-ID.
  • By default, use 1/2/4/8/10 second fallback backoff and stop after five consecutive failed attempts. A server retry: value takes precedence.
  • Stop reconnecting after a final response, timeout or cancellation, explicit close, or when the stream has no resumable event ID.
  • Add the sse-retry conformance path and remove it from the expected-failure baseline.

Tests

  • vendor/bin/phpunit — 1693 tests, 4416 assertions, 7 skipped
  • vendor/bin/phpstan analyse --memory-limit=-1
  • vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php-cs-fixer.dist.php
  • make docs
  • composer validate --strict
  • sse-retry conformance — 3/3

Fixes #327.

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

Successfully merging this pull request may close these issues.

[Client] Implement SSE reconnect with Last-Event-ID

1 participant