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

Keep-alive function follows WS protocol (not graphql-ws) #155

Open
gravgaard opened this issue Nov 6, 2024 · 1 comment
Open

Keep-alive function follows WS protocol (not graphql-ws) #155

gravgaard opened this issue Nov 6, 2024 · 1 comment

Comments

@gravgaard
Copy link

gravgaard commented Nov 6, 2024

When setting the WithKeeplive
WithKeepAlive(time.time) an asynchronous routine is enabled during pings using the underlying websocket handler from https://github.com/coder/websocket. This underlying handler uses the web socket protocol https://datatracker.ietf.org/doc/html/rfc6455#section-11.8 which is not similar to the sub-protocols graphql-ws / subscriptions-transport-ws Which is supported by this library.

Concretely I experienced that a Graphql Server (implemented with https://github.com/99designs/gqlgen did not understand the pings because of the protocol-confussion, thus leading a connection being dropped and reinitialized.

I do not know whether this is how most servers are implemented, but the protocol is set upon the 101 switch protocol request by the client and then the server choses an appropiate messageExchanger based on the protocol

@hgiasac
Copy link

hgiasac commented Dec 13, 2024

@gravgaard sorry for the late reply.

Yes, the WithKeepAlive config is used by the WebSocket client. IIRC this follows the implementation of the WebSocket client library. However, it's disabled by default. It should be fine if you don't configure it.

The keep-alive ping-pong events of subscription specs are handled from the server side so the client mostly doesn't need to do anything. It just waits for the ping from the server and reply back.

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

No branches or pull requests

2 participants