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

When sending out a heartbeat, also send a ping frame #1

Open
wants to merge 1 commit into
base: cowboy-28
Choose a base branch
from

Conversation

DefV
Copy link

@DefV DefV commented Aug 2, 2022

My current implementation of the client can be quiet for hours, which would
trigger the 60-second timeout in cowboy_websocket. Adding a ping-frame
forces clients to respond with a pong-frame, restarting the loop. In testing
I found that some browsers work better with some payload data added, so I'm
adding the same "h" string as payload.

I figured I'd send a PR here since Ably seems to be maintaining the most
up-to-date & worked on fork.

I'm quite new to erlang development so any pointers on how to improve the
implementation are welcome. I'm not very proud of how I forced it in there,
and feel like it would be better to put this in sockjs_ws_handler instead,
but that felt like a bigger refactor.

My current implementation of the client can be quiet for hours, which would
trigger the 60-second timeout in `cowboy_websocket`. Adding a ping-frame
forces clients to respond with a pong-frame, restarting the loop. In testing
I found that some browsers work better with some payload data added, so I'm
adding the same "h" string as payload.
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.

1 participant