MuhammetM
Apify & Crawlee2mo ago
3 replies
Muhammet

SSE Dead Client Detection Issue Behind Apify Standby Proxy

In my SSE endpoint running under Apify Standby mode, the server is unable to reliably detect when clients disconnect. Even when the client closes the browser or loses network connection, the Apify proxy keeps the connection to the Actor open, so the server never receives a proper “disconnect” signal. As a result, the server continues to treat the connection as active and keeps streaming data to a client that no longer exists. Over time, this leads to accumulated dead connections, unnecessary resource usage, and inaccurate connection metrics.

The core issue appears to be that Apify’s proxy does not propagate the actual client disconnect to the Actor. Therefore:
-
close
,
error
, and timeout events are never triggered on the server side,
- the server continues writing data with no feedback that the real client is gone,
- stale SSE connections remain in memory and cannot be cleaned up correctly.

I currently rely on several heuristic workarounds, such as:
- marking a connection as dead if no successful write occurs within a certain time window,
- monitoring pending writes to detect possible dead streams,
- running periodic checks to validate connection state.

These strategies help mitigate the issue but are not fully reliable, since they rely on indirect signals rather than a definitive disconnect notification from the network layer.

For this reason, I need clarification on the following points:

1. Does Apify Standby mode enforce any specific timeout, keep-alive, or proxy behavior for SSE connections?
2. Is there any officially recommended method to detect dead SSE clients when running behind the Apify proxy?
3. Can additional HTTP headers influence how the proxy handles disconnects or keep-alives?
Was this page helpful?