Skip to content

Add ability to set subscription timeout via config #1247

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

Open
NeoPhi opened this issue Jun 25, 2020 · 5 comments · May be fixed by #1280
Open

Add ability to set subscription timeout via config #1247

NeoPhi opened this issue Jun 25, 2020 · 5 comments · May be fixed by #1280

Comments

@NeoPhi
Copy link

NeoPhi commented Jun 25, 2020

It would be ideal if the middleware configuration and the defaultLinkCreator supported passing an override for the SubscriptionClient timeout instead of having it hard coded to 20000 as shown here:

https://github.com/prisma-labs/graphql-playground/blob/fa91e1b6d0488e6b5563d8b472682fe728ee0431/packages/graphql-playground-react/src/state/sessions/fetchingSagas.ts#L81

@lunaroyster
Copy link

Also here:

https://github.com/prisma-labs/graphql-playground/blob/824c7a57f0284f022726a8b8840aafc3e8720ccd/packages/graphql-playground-react/src/components/PlaygroundWrapper.tsx#L521

there's a 1000 ms limit to making the connection. I recently moved to the other side of the world, and was wondering why my subscriptions are broken 🤦

@fiLLLip
Copy link

fiLLLip commented Sep 30, 2020

https://github.com/prisma-labs/graphql-playground/blob/824c7a57f0284f022726a8b8840aafc3e8720ccd/packages/graphql-playground-react/src/components/PlaygroundWrapper.tsx#L521

there's a 1000 ms limit to making the connection.

I am facing an issue when using AWS Api Gateway with Lambda behind it. Cold starts sometimes exceed 1000ms, making the subscription fail. I think I'll create a PR for this.

@fiLLLip
Copy link

fiLLLip commented Sep 30, 2020

Actually, after doing some more research, it looks like the issue three-folded.

  1. subscriptions-transport-ws uses backo2 to calculate timeout based on minTimeout and Timeout. minTimeout is set to 1000, and since this is first try it sets the timeout to 1000ms, even though we want to manually try again. Could be for internal retry or something, but if I click play 10 times the calculated timeout stays the same (1000ms).
  2. fetchingSagas does not specify minTimeout (hence default 1000ms).
  3. When not specifying a specific subscriptionEndpoint, the wrapper tries a connection to the regular enpoint, setting ws(s) as protocol, and timing out after 1000ms.

fiLLLip added a commit to fiLLLip/graphql-playground that referenced this issue Sep 30, 2020
Forcing timeout to be set value by setting both timeout and minTimeout on the subscription client
@guisehn
Copy link

guisehn commented Mar 9, 2021

This would help fix an issue where if the GraphQL server using subscription-transport-ws has a keepAlive set to anything above 20s, the subscription-transport-ws client used by graphql-playground kills the websocket connection after 20s.

@Shane32
Copy link

Shane32 commented Mar 21, 2022

@sungam3r I was having trouble testing a new GraphQL.NET server implementation with a 25sec keep-alive timer because Playground (and/or subscription-transport-ws) apparently terminates connections after 20sec of not receiving a keep-alive packet (see above) -- but only if a keepalive packet has been received. If no keep-alive packets are received, it will keep the connection alive indefinitely. Moreover, it does not reset its timer if another packet has been received, so the server is required to send keep-alive packets continuously even with a steady stream of data.

The current GraphQL.NET Server implementation does not send keep-alive packets at all.

Note that Playground does not appear to support the newer graphql-ws package at all. See below:

Link to GraphQL.Net Server:

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

Successfully merging a pull request may close this issue.

5 participants