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 ReceiveAsync hangs forever on server #26117

Closed
osexpert opened this issue Sep 20, 2020 · 3 comments
Closed

WebSocket ReceiveAsync hangs forever on server #26117

osexpert opened this issue Sep 20, 2020 · 3 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-websockets Includes: WebSockets ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@osexpert
Copy link

NetCore\AspNetCore 3.1.8
Kestrel, running in debug
Simple example, middleware doing
var ws = await context.WebSockets.AcceptWebSocketAsync();
await ws.ReceiveAsync(buff, CancellationToken.None);

Client connect:
var ws = new ClientWebSocket();
await ws.ConnectAsync(new Uri("ws://host/ws/test"), CancellationToken.None);
await ws.ReceiveAsync(buff, CancellationToken.None);

Pull out network cable. After a while, client throws WebSocketException (as expected).
But server is "blocking" on ReceiveAsync forever. Seems there is something wrong with the pingpong logic? Pingpong is keeping the client alive but server does not care when client stops responding to pingpong and will Recieve forever in vain. I don't see how WebSocket can be usable in real life with this behaviour?

@ghost
Copy link

ghost commented Sep 20, 2020

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

@stephentoub stephentoub transferred this issue from dotnet/runtime Sep 20, 2020
@Tratcher Tratcher added the feature-websockets Includes: WebSockets label Sep 20, 2020
@osexpert
Copy link
Author

osexpert commented Sep 20, 2020

After being assigned area-websockets I see 3 other cases complaining about the same and being closed.
In any case, this is higly inconsistent that the client actually closes while the server does not. I can accept this behavior if you change the client to also hang forever:-D

@BrennanConroy
Copy link
Member

Triage notes: The WebSocket on the server side will send Pings every 2 minutes by default. The problem is that the RFC doesn't say that you should kill the connection if a Pong isn't received in response to a Ping so the WebSocket is just going to stay open. If you wait for the TCP timeout (which could be 15+ minutes on Windows) then you will see that the WebSocket is closed at that point.

We are tracking this sort of issue in #24614

@BrennanConroy BrennanConroy added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Sep 21, 2020
@ghost ghost added the Status: Resolved label Sep 21, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Oct 25, 2020
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-websockets Includes: WebSockets ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

5 participants