WebSocket ReceiveAsync hangs forever on server #26117
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
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?
The text was updated successfully, but these errors were encountered: