dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.49k stars 10.04k forks source link

[HTTP/3] Better handle connection close by browser #37835

Open JamesNK opened 3 years ago

JamesNK commented 3 years ago

When a browser is closed it shuts down the QUIC transport rather than aborting. That leaves unidirection control streams in an unhealthy state.

We need to know whether a connection was aborted or shutdown which will require work in System.Net.Quic.

Example logs from browser close:

[13:45:13.266] dbug: HttpEventSourceListener[0]
      <- Event Private.InternalDiagnostics.System.Net.Quic - Info : State#258006,NativeCallbackHandler,[conn][0x21660D75020] Connection received event SHUTDOWN_INITIATED_BY_TRANSPORT ->
[13:45:13.267] dbug: HttpEventSourceListener[0]
      <- Event Private.InternalDiagnostics.System.Net.Quic - Info : State#9010854,HandleEvent,[strm][0x21660D762E0] Stream received event SHUTDOWN_COMPLETE ->
[13:45:13.267] dbug: HttpEventSourceListener[0]
      <- Event Private.InternalDiagnostics.System.Net.Quic - Info : State#9010854,HandleEventConnectionClose,[strm][0x21660D762E0] Stream handling connection [conn][0x21660D75020] close with code 0 ->
[13:45:13.290] dbug: HttpEventSourceListener[0]
      <- Event Private.InternalDiagnostics.System.Net.Quic - Info : State#16802227,HandleEvent,[strm][0x2166102F510] Stream received event SEND_SHUTDOWN_COMPLETE ->
[13:45:13.290] dbug: HttpEventSourceListener[0]
      <- Event Private.InternalDiagnostics.System.Net.Quic - Info : State#16802227,HandleEvent,[strm][0x2166102F510] Stream received event SHUTDOWN_COMPLETE ->
[13:45:13.290] dbug: HttpEventSourceListener[0]
      <- Event Private.InternalDiagnostics.System.Net.Quic - Info : State#16802227,HandleEventConnectionClose,[strm][0x2166102F510] Stream handling connection [conn][0x21660D75020] close with code 0 ->
[13:45:13.291] dbug: HttpEventSourceListener[0]
      <- Event Private.InternalDiagnostics.System.Net.Quic - Info : State#258006,NativeCallbackHandler,[conn][0x21660D75020] Connection received event SHUTDOWN_COMPLETE ->
[13:45:13.291] dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Quic[11]
      Stream id "0HMCO37DOFV64:00000002" read aborted by peer with error code 0.
[13:45:13.292] dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Quic[12]
      Stream id "0HMCO37DOFV64:00000003" write aborted by peer with error code 0.
[13:45:13.292] dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Quic[10]
      Stream id "0HMCO37DOFV64:00000003" shutting down writes because: "Connection aborted by peer (0).".
[13:45:13.273] dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Quic[5]
      Connection id "0HMCO37DOFV64" aborted by peer with error code 0.
      System.Net.Quic.QuicConnectionAbortedException: Connection aborted by peer (0).
         at System.Net.Quic.Implementations.MsQuic.MsQuicConnection.AcceptStreamAsync(CancellationToken cancellationToken)
         at System.Net.Quic.QuicConnection.AcceptStreamAsync(CancellationToken cancellationToken)
         at Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Internal.QuicConnectionContext.AcceptAsync(CancellationToken cancellationToken) in C:\Development\Source\AspNetCore\src\Servers\Kestrel\Transport.Quic\src\Internal\QuicConnectionContext.cs:line 97
ghost commented 2 years ago

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.