HP_TIMEOUT_CLIENT=30s too short for persistent MCP SSE streams — causes session termination
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 54
- Forks
- 10
- Avg merge
- 40m
- Merged PRs (30d)
- 3
Description
Summary
The HaRP proxy deployed by Nextcloud AIO ships with HP_TIMEOUT_CLIENT=30s. This timeout is too short for persistent MCP sessions (MCP Streamable HTTP, protocol version 2025-03-26), causing any stateful MCP client session to be terminated after ~30 seconds of the GET stream being idle.
Steps to Reproduce
- Install context_agent on Nextcloud AIO with HaRP enabled
- Connect a MCP client using Streamable HTTP with persistent sessions (
stateless_http=False) - Client opens a persistent GET SSE stream (server→client push channel) after
initialize - After ~30 seconds of no activity on the GET stream, HaRP closes the connection
- The server's
StreamableHTTPServerTransportdetects the closed stream and callsterminate() - Client receives
McpError: Session terminatedon the next keepalive ping or request - Client reconnects — loop repeats indefinitely
Root Cause
HaRP's HP_TIMEOUT_CLIENT=30s applies to the entire client-side HTTP connection, including long-lived SSE streams. The MCP Streamable HTTP protocol requires a persistent GET SSE stream for server→client push messages. This stream is intentionally idle (no data flows unless the server pushes) — but HaRP's client timeout doesn't distinguish between a truly idle connection and a healthy long-lived SSE stream.
HP_TIMEOUT_CLIENT=30s # closes any client connection after 30s idle
HP_TIMEOUT_SERVER=1800s # server-side correctly set to 30 minutes
The asymmetry between client (30s) and server (1800s) timeouts is the issue.
Observed in Logs
Container logs (nc_app_context_agent):
Created new transport with session ID: 9d7d0dc8...
Terminating session: 9d7d0dc8... ← after exactly ~12s (HaRP closes the GET stream)
Hermes Agent logs:
MCP server 'Nextcloud' keepalive failed, triggering reconnect (state: connected → degraded): McpError: Session terminated
Expected Behavior
HP_TIMEOUT_CLIENT should be set to a value that accommodates long-lived SSE streams, e.g. 600s or higher. Alternatively, AIO documentation should note that MCP clients require an increased HP_TIMEOUT_CLIENT.
Suggested Fix
Increase the default HP_TIMEOUT_CLIENT for AIO HaRP deployments:
HP_TIMEOUT_CLIENT=600s # 10 minutes — accommodates MCP SSE streams
Or expose HP_TIMEOUT_CLIENT as a configurable AIO environment variable so administrators can set it without recreating the HaRP container manually.
Workaround
Recreate the nextcloud-aio-harp container manually with HP_TIMEOUT_CLIENT=600s. This override is lost on every AIO update.
Environment
- Nextcloud AIO: latest (Nextcloud 33.0.7)
- HaRP:
ghcr.io/nextcloud/nextcloud-appapi-harp:release - Default
HP_TIMEOUT_CLIENT=30s - MCP client: any client using Streamable HTTP persistent sessions (Hermes Agent, Claude Code, etc.)
Relation
This issue is a companion to nextcloud/context_agent#227 — even when that issue is fixed (stateless_http=False), persistent MCP sessions will still fail unless this timeout is also addressed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating where HaRP defines or passes HP_TIMEOUT_CLIENT for the AIO deployment, then compare it with HP_TIMEOUT_SERVER and the persistent MCP SSE behavior described here. Verify the change with a long-lived idle GET stream and confirm that the session remains usable beyond 30 seconds; document or expose the setting if the default cannot be changed safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100