Skip to content

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

Open
DefV wants to merge 1 commit into
ably-forks:cowboy-28from
DefV:ping-on-heartbeat
Open

When sending out a heartbeat, also send a ping frame#1
DefV wants to merge 1 commit into
ably-forks:cowboy-28from
DefV:ping-on-heartbeat

Conversation

@DefV

@DefV DefV commented Aug 2, 2022

Copy link
Copy Markdown

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