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

Configure a subgraph websocket ping interval #4621

Closed
smyrick opened this issue Feb 8, 2024 · 1 comment · Fixed by #4802
Closed

Configure a subgraph websocket ping interval #4621

smyrick opened this issue Feb 8, 2024 · 1 comment · Fixed by #4802
Assignees

Comments

@smyrick
Copy link
Member

smyrick commented Feb 8, 2024

Is your feature request related to a problem? Please describe.
The graphql-ws protocol supports sending a Ping message. This is useful for detecting failed connections, displaying latency metrics or other types of network probing.

If I have opened a passthrough mode subscription to my subgraph the connection is all good. But we're facing issues with longer intervals between messages. Apollo Router logs a TCP connection reset when no messages have been sent beyond our load balancer after a connection idle timeout.

By capturing traffic, we confirmed neither Apollo Router nor the subgraph actively sends pings/heartbeats on the WebSocket session. Both can respond to heartbeats, but both services are just sitting passive and our LB eventually closes the idle connection.

Describe the solution you'd like
Add an option to enable sending a Ping message to a subgraph from Router on a set interval. Having this off by default is ok, but we need an option to turn it on for our subgraphs

subscription:
  enabled: true
  mode:
    passthrough:
      all: 
        path: /subscriptions
        protocol: graphql_ws
        ping_interval: 300 # Some option probably in seconds is fine

Describe alternatives you've considered
To keep the connection open we can go and update our subgraph code to also send Ping message because this is bi-directional but we may have to do that across many subgraphs and unfortunately some libraries like DGS don't have support to configure a ping interval either

Additional context
This is not a concern if we use the HTTP callback protocol instead

@bnjjj
Copy link
Contributor

bnjjj commented Mar 6, 2024

The implementation of ping message should be implemented in that file and maybe especially there, where you could create an interval stream or so to directly send ping message every X seconds configured. I think it would be enough. But yes we should try to keep the original behavior and set a new option to send ping messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants