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

WebSocket: Ping and Pong #15430

Closed
sinclairzx81 opened this issue Aug 9, 2022 · 5 comments
Closed

WebSocket: Ping and Pong #15430

sinclairzx81 opened this issue Aug 9, 2022 · 5 comments
Labels
ext/websocket related to the ext/websocket crate suggestion suggestions for new features (yet to be agreed)

Comments

@sinclairzx81
Copy link
Contributor

sinclairzx81 commented Aug 9, 2022

Hi, Would it be possible to include the methods .ping() and .pong() on Deno's Web Socket implementation? It's noted that while browsers do not support sending these control frames, they can be a server side requirement if deploying WebSocket servers behind load balanced environments.

Infrastructure such as AWS's Application / Network Load Balancer (as well as many other load balancers) will automatically terminate idle connections. Applications can mitigate LB termination by periodically sending ping() control frames down to each connected client. Because ping frames are sent out of band from the sockets messaging channel, server applications can keep their connection keep alive logic and application protocol logic separate (with the added benefit of browser Web Sockets not seeing ping control frames at all)

Without this functionality, it does raise quite a few challenges porting existing application protocols to run on Deno. This is due to applications often omitting ping control frames in the applications protocol itself (as it's generally understood that these control frames are already provided as part of the RFC6455 specification)

RFC

https://www.rfc-editor.org/rfc/rfc6455#section-5.5.2
https://www.rfc-editor.org/rfc/rfc6455#section-5.5.3

Rust

https://docs.rs/ws/latest/ws/struct.Frame.html#method.ping
https://docs.rs/ws/latest/ws/struct.Frame.html#method.pong

Node

https://github.com/websockets/ws/blob/master/lib/sender.js#L209
https://github.com/websockets/ws/blob/master/lib/sender.js#L252

Would it be possible to include these methods?

@sinclairzx81
Copy link
Contributor Author

Closed due to radio silence on this issue.

@littledivy
Copy link
Member

Seems desirable. Reopening.

@littledivy littledivy reopened this Sep 3, 2022
@littledivy littledivy added suggestion suggestions for new features (yet to be agreed) ext/websocket related to the ext/websocket crate labels Sep 3, 2022
@littledivy
Copy link
Member

Spec issue: whatwg/websockets#10

@alexgleason
Copy link
Contributor

alexgleason commented May 25, 2024

I discovered that ping/pong frames are sent automatically thanks to: #13172

But I had to set { idleTimeout: 30 } on the call to Deno.upgradeWebSocket to prevent nginx from killing the connection.

@lucacasonato
Copy link
Member

I am going to close this as we automatically ping-pong now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/websocket related to the ext/websocket crate suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

4 participants