Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSE Keep-Alive #6035

Closed
demius opened this issue Apr 7, 2023 · 6 comments · Fixed by #6133
Closed

SSE Keep-Alive #6035

demius opened this issue Apr 7, 2023 · 6 comments · Fixed by #6133
Labels
Area: Subscriptions Issue is related to Subscriptions or a Subscription Provider 🎉 enhancement New feature or request 🌶️ hot chocolate
Milestone

Comments

@demius
Copy link

demius commented Apr 7, 2023

Product

Hot Chocolate

Is your feature request related to a problem?

Subscriptions over SSE work really well, but a problem we have is that there's no keep-alive mechanism. This manifests itself when using something like Azure Application Gateway which closes idle connections after a pre-configured timeout. There's an open discussion regarding this topic in the Web Hypertext Application Technology Working Group repository.

The solution you'd like

SSE support should be more explicit and allow a configurable keep-alive message to be dispatched to all connected clients. Alternatively, is there an injectable interface which allows us to get all connected subscribers and manually issue keep-alives in a background service?

@demius demius added the 🎉 enhancement New feature or request label Apr 7, 2023
@michaelstaib
Copy link
Member

Hey @enisdenjo I saw similar things with other gateways ... is that something that can be added to the protocol ... to send a keep alive message?

@michaelstaib michaelstaib added 🌶️ hot chocolate Area: Subscriptions Issue is related to Subscriptions or a Subscription Provider labels Apr 12, 2023
@enisdenjo
Copy link

graphql-sse itself pings clients every 12 seconds.

Legacy proxy servers are known to, in certain cases, drop HTTP connections after a short timeout. To protect against such proxy servers, authors can include a comment line (one starting with a ':' character) every 15 seconds or so.

SSE spec "Authoring notes" section

Essentially, issuing an empty comment message (:\n\n) is considered a keep-alive ping. The graphql-sse client ignores these empty messages, and so does the browser native EventSource.

@demius
Copy link
Author

demius commented Apr 12, 2023

Thanks @enisdenjo, but how can I submit this empty message to all connected/subscribed clients? What I was thinking of was having some kind of background service which sends a keep-alive payload to all connected subscribers (regardless of topic), but I've been digging around in the transport code and I can't find an injectable service I can use for this purpose. Does such a service exist, or would I need to create a separate subscription just for this?

@enisdenjo
Copy link

Sorry but I am not familiar with this library. I'd say @michaelstaib is the better person to ask.

@demius
Copy link
Author

demius commented May 9, 2023

Any suggestions on this topic @michaelstaib?

@michaelstaib michaelstaib added this to the HC-13.1.0 milestone May 9, 2023
@michaelstaib
Copy link
Member

We will implement that with 13.1 .... thanks @enisdenjo for the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Subscriptions Issue is related to Subscriptions or a Subscription Provider 🎉 enhancement New feature or request 🌶️ hot chocolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants