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 ping/pong handler in tapir websocket protocol #1458

Merged
merged 5 commits into from
Sep 11, 2022

Conversation

rolang
Copy link
Contributor

@rolang rolang commented Sep 4, 2022

Hi, I believe I found a bug in the protocol while investigating an issue we have with our websocket server using the graphql-ws client with keepAlive config (see config description). Currently It causes the server to close the websocket after it receives a ping message instead of responding with pong.

This update would make it respond with a "pong" message to "ping" by default, or after a successfully executed "onPing" hook if defined.

@rolang
Copy link
Contributor Author

rolang commented Sep 4, 2022

Ah, just realised that this would cause issues on receiving the pong message from client when keepAlive config is set server-side.
I guess we could keep the response to pong like before and just add the ping case.

@rolang
Copy link
Contributor Author

rolang commented Sep 4, 2022

Ok fixed...
Could maybe cover that in tests too.

@rolang
Copy link
Contributor Author

rolang commented Sep 5, 2022

Just made the ping hook accepting an optional payload, because one may want to run it independent from given payload, e.g. to perform something like health checks? (ping).

@ghostdogpr
Copy link
Owner

Thanks for your work, I will have more time to review this in the weekend.

@paulpdaniels in case you have time to take a look 😄

Copy link
Owner

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ghostdogpr ghostdogpr merged commit 2aaae7e into ghostdogpr:series/2.x Sep 11, 2022
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.

None yet

3 participants