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

Feature request: Enable Websocket ping-pong and timeout #60620

Closed
zackliu opened this issue Oct 19, 2021 · 3 comments
Closed

Feature request: Enable Websocket ping-pong and timeout #60620

zackliu opened this issue Oct 19, 2021 · 3 comments
Milestone

Comments

@zackliu
Copy link

zackliu commented Oct 19, 2021

Currently, ManagedWebsocket only sends Pong to keep live. It means it have to depend on TCP timeout to terminate a half-open connection. TCP timeout depends on OS and it's around 15 minutes in Linux, which is too long especially for the Websocket server side.

Although RFC is not described clearly about what should do if no pong received after a period of time, I suggest we can have an option to enable a timeout.

The purpose here is to make sure the other side of connection is still alive, so as long as the connection can receive some bytes, we can treat it as alive. Sending ping is just force the other side to send something back.

I propose sending Ping instead of Pong periodically here:
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs#L546
And adding another periodically check to verify whether the connection not received anything for too long.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Oct 19, 2021
@ghost
Copy link

ghost commented Oct 19, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Currently, ManagedWebsocket only sends Pong to keep live. It means it have to depend on TCP timeout to terminate a half-open connection. TCP timeout depends on OS and it's around 15 minutes in Linux, which is too long especially for the Websocket server side.

Although RFC is not described clearly about what should do if no pong received after a period of time, I suggest we can have an option to enable a timeout.

The purpose here is to make sure the other side of connection is still alive, so as long as the connection can receive some bytes, we can treat it as alive. Sending ping is just force the other side to send something back.

I propose sending Ping instead of Pong periodically here:
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs#L546
And adding another periodically check to verify whether the connection not received anything for too long.

Author: zackliu
Assignees: -
Labels:

area-System.Net, untriaged

Milestone: -

@CarnaViire
Copy link
Member

Thanks @zackliu. This feature request is actually a duplicate of #48729, so I'm going to close this one.

If you are interested in the feature, please upvote #48729, it would help us prioritize!

@CarnaViire
Copy link
Member

Duplicate of #48729

@CarnaViire CarnaViire marked this as a duplicate of #48729 Oct 19, 2021
@karelz karelz added this to the 7.0.0 milestone Oct 19, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 18, 2021
@karelz karelz removed the untriaged New issue has not been triaged by the area owner label Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants