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

Fix pong messages to follow the graphql websocket protocol. #116

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

vorporeal
Copy link
Contributor

The graphql websocket protocol uses messages with the text opcode and payload {"type": "ping"}/{"type": "pong"} instead of using the ping and pong opcodes.

At present, graphql-ws-client interprets a text message with payload {"type": "ping"} but responds with a pong message. This can lead to servers dropping the connection, due to receiving a message that doesn't conform with the graphql-transport-ws protocol (see: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md#ping).

Message::graphql_pong() is already used in ClientBuilder::build() to respond to any ping messages received during connection initialization, but it isn't used for pings received after a subscription has been established.

I discovered this when updating our codebase from graphql-ws-client 0.6.0 to graphql-ws-client 0.10.1, and noticed that the server would respond with a close frame after our client responded to a server-sent ping frame.

@obmarg
Copy link
Owner

obmarg commented Aug 21, 2024

Thanks @vorporeal

@obmarg obmarg merged commit a4e7eb8 into obmarg:main Aug 21, 2024
2 checks passed
@obmarg
Copy link
Owner

obmarg commented Aug 21, 2024

Released in v0.10.2

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 this pull request may close these issues.

2 participants