Open iconics-milan opened 3 years ago
Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.
Author: | iconics-milan |
---|---|
Assignees: | - |
Labels: | `area-System.Net`, `untriaged` |
Milestone: | - |
After experimenting more, I found that my code was missing a ctx.Response.Close() when done with the WebSocket (ctx is the HttpListenerContext). With that call in place, the TCP connection gets torn down abruptly (as expected) when no CloseAsync() is called before. I guess there is no reason not to call Close() on WebSocket responses. This still means that Abort() does nothing, but it isn't an issue for me - I am simply not calling it anymore.
Triage: Windows works because it is implemented on top of http.sys Looks like something we might want to address in the managed implementation.
It might be as simple as make NetworkStream
to own the Socket
. We need to validate if HttpListener
will be ok with that.
We would appreciate help in the investigation here ...
Description
Calling Abort() or Dispose() on a server WebSocket originating from a HttpListener does nothing with the underlying TCP connection, when run on Linux. The connection simply remains open. On Windows, it properly aborts the TCP connection.
Configuration
Tried on .NET Core 2.1, 3.1, 5.0 on Ubuntu - all with the same result. Works on Windows with all these versions.
Code
This code gets stuck on Linux, but finishes on Windows: