Long-lived HTTP streams: proxy timeouts and buffering
SSE and WebSocket streams depend on every hop between client and application. Proxies, CDNs, and load balancers can impose idle timeouts; buffering can delay data. HTTP/1.1 persistence reuses a connection after completed exchanges, while SSE/WebSocket keep a stream or session open. HTTP/2 multiplexes streams, so do not copy HTTP/1.1 settings blindly.
SSE and WebSocket streams depend on every hop between client and application. Proxies, CDNs, and load balancers can impose idle timeouts; buffering can delay data. HTTP/1.1 persistence reuses a connection after completed exchanges, while SSE/WebSocket keep a stream or session open. HTTP/2 multiplexes streams, so do not copy HTTP/1.1 settings blindly.
Timeouts often measure idle gaps between reads, not total duration. NGINX proxy_read_timeout defaults to 60 seconds between upstream reads; its WebSocket proxy also closes by default after 60 seconds without upstream data. Check the deployed version and every hop.
location /events {
proxy_pass http://app;
proxy_buffering off;
proxy_read_timeout 90s;
}90 seconds is illustrative, not a universal recommendation. With buffering disabled, NGINX forwards data as received; the app must still emit valid SSE and flush. Record which side closes and when, compare idle limits, inspect buffering/compression/flush, and monitor open connections. SSE comments or WebSocket pings can keep an idle path active but must occur sooner than the shortest hop timeout. Idle connections still consume resources.
Sources
[NGINX proxy module](https://nginx.org/en/docs/http/ngx_http_proxy_module.html)
[NGINX WebSocket proxying](https://nginx.org/en/docs/http/websocket.html)
[MDN Using server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)