modelcontextprotocol / modelcontextprotocol/java-sdk
SSE client rejects valid `retry:` field and ignores reconnection timing (Streamable HTTP)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 3.7k
- Forks
- 1.1k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 9
Beschreibung
Bug description
The client SSE line parser in ResponseSubscribers rejects the standard SSE retry: field, throwing:
io.modelcontextprotocol.spec.McpTransportException: Invalid SSE response. Status code: 200 Line: retry: 500
Per the SSE specification, retry: sets the stream's reconnection time, and unknown fields MUST be ignored (never error the stream). Because of this, the Streamable HTTP client:
- can error a live SSE stream when the server sends a
retry:line, and - does not honor the server-provided reconnection delay, reconnecting immediately.
This is the MUST-level client-sse-retry-timing failure already noted as a known limitation in conformance-tests/VALIDATION_RESULTS.md.
Environment
- java-sdk
main(2.0.1-SNAPSHOT) - Java 17+
- Transport:
HttpClientStreamableHttpTransport(client), SSE / Streamable HTTP
Steps to reproduce
Run the official MCP conformance sse-retry client scenario:
./mvnw clean package -DskipTests -pl conformance-tests/client-jdk-http-client -am
npx -y @modelcontextprotocol/conformance client \
--command "java -jar conformance-tests/client-jdk-http-client/target/client-jdk-http-client-2.0.1-SNAPSHOT.jar" \
--scenario sse-retry
Observed:
Error: Invalid SSE response. Status code: 200 Line: retry: 500
[client-sse-retry-timing ] FAILURE Client MUST respect the retry field (reconnected ~0ms instead of 500ms)
[client-sse-last-event-id] WARNING Client SHOULD send Last-Event-ID on reconnection
OVERALL: FAILED
Expected behavior
- The SSE parser parses/ignores
retry:(and any unknown SSE field) without erroring the stream. - On reconnection after a drop, the client waits the server-specified
retryinterval before reconnecting.
Minimal reproducible example
Feeding the SSE lines id: e1 / retry: 500 / data: hello / (blank) to the SSE line subscriber currently throws McpTransportException instead of yielding a single event.
Proposed scope (two parts)
- Parser robustness (small, self-contained): parse
retry:and ignore unknown fields inResponseSubscribers. (Implemented locally with unit tests.) - Reconnect timing: honor the parsed
retryvalue before reconnecting inHttpClientStreamableHttpTransport/DefaultMcpTransportStream. This touches theMcpTransportStreamSPI, so I'd like to confirm the preferred approach before opening a PR.
The related Last-Event-ID SHOULD warning appears covered by #830, so I would keep it out of scope here.
Happy to open a PR for part 1 immediately and follow up on part 2 per maintainer guidance.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem SSE-Zeilenabonnenten in ResponseSubscribers und seinen Unit-Tests und stelle dabei den minimalen Retry-Fall: 500 nach. Verfolge anschließend die Behandlung der Wiederverbindung durch HttpClientStreamableHttpTransport und DefaultMcpTransportStream, einschließlich der McpTransportStream SPI. Führe das sse-retry-Konformitätsszenario aus; abgeschlossen ist die Aufgabe, wenn die Retry-Felder nicht mehr beim Parsen fehlschlagen und die Wiederverbindung die vom Server bereitgestellte Verzögerung berücksichtigt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- api, networking
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100