Open
Description
Describe the bug
AspNetCore 2.1 doesn't automatically close the socket when a ConnectionHandler's OnConnectedAsync returned Task completes. On AspNetCore 2.2, the socket is automatically closed on Task completion. If the connection handler implementation never closes the socket, then the socket remains open indefinitely, even after Dispose has been called on the IWebHost.
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core '2.1'
- Create a connection handler which returns a completed Task. Start the webhost and create a connection to the configured port. Dispose the webhost. Clients socket remains connected and is able to call send and receive on the socket (which don't complete as there's nothing reading or writing on the server side of the socket).
Expected behavior
When calling Dispose on the webhost, all sockets will get disconnected.
Additional context
I discovered this when developing CoreWCF. If you need a repro, I can make a custom branch where our unit tests fail demonstrating this issue.