Fix pong messages to follow the graphql websocket protocol. #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thegraphql-transport-ws
protocol (see: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md#ping).Message::graphql_pong()
is already used inClientBuilder::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
tographql-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.