diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs index caf39a7ac7bd0..58e9594691b91 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs @@ -388,6 +388,13 @@ private async Task SendSettingsAsync() await _clientControl.WriteAsync(_pool.Settings.Http3SettingsFrame, CancellationToken.None).ConfigureAwait(false); } + catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted) + { + Debug.Assert(ex.ApplicationErrorCode.HasValue); + Http3ErrorCode code = (Http3ErrorCode)ex.ApplicationErrorCode.Value; + + Abort(HttpProtocolException.CreateHttp3ConnectionException(code, SR.net_http_http3_connection_close)); + } catch (Exception ex) { Abort(ex); @@ -577,6 +584,13 @@ private async Task ProcessServerStreamAsync(QuicStream stream) { // ignore the exception, we have already closed the connection } + catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted) + { + Debug.Assert(ex.ApplicationErrorCode.HasValue); + Http3ErrorCode code = (Http3ErrorCode)ex.ApplicationErrorCode.Value; + + Abort(HttpProtocolException.CreateHttp3ConnectionException(code, SR.net_http_http3_connection_close)); + } catch (Exception ex) { Abort(ex);