cosmo icon indicating copy to clipboard operation
cosmo copied to clipboard

Heartbeat on SSE connections

Open jerem1e opened this issue 5 months ago • 3 comments

Component(s)

router

Is your feature request related to a problem? Please describe.

When using WunderGraph SSE subscriptions, connections often pass through intermediate gateways, proxies, or load balancers. These components typically have idle timeout configurations that automatically close seemingly inactive connections after a certain period (e.g., 60-120 seconds).

Describe the solution you'd like

Implement a configurable feature within the WunderGraph Gateway/Router to periodically send lightweight SSE comment heartbeats (:\n\n) on active subscription connections. E.g. like this:

subscriptions:
  sse:
    enableHeartbeats: true
    heartbeatInterval: 30s # send a heartbeat every 30 seconds

Describe alternatives you've considered

No response

Additional context

Here is a mozilla guide about SSE where this is mentioned: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format

jerem1e avatar Jun 28 '25 09:06 jerem1e