diff --git a/samples/Http2SampleApp/Program.cs b/samples/Http2SampleApp/Program.cs index 842ee9c795..0825c6e3d5 100644 --- a/samples/Http2SampleApp/Program.cs +++ b/samples/Http2SampleApp/Program.cs @@ -36,7 +36,6 @@ namespace Http2SampleApp options.Listen(IPAddress.Any, basePort, listenOptions => { listenOptions.Protocols = HttpProtocols.Http1; - listenOptions.UseConnectionLogging(); }); // TLS Http/1.1 or HTTP/2 endpoint negotiated via ALPN @@ -44,7 +43,6 @@ namespace Http2SampleApp { listenOptions.Protocols = HttpProtocols.Http1AndHttp2; listenOptions.UseHttps("testCert.pfx", "testPassword"); - // listenOptions.UseConnectionLogging(); listenOptions.ConnectionAdapters.Add(new TlsFilterAdapter()); }); @@ -53,7 +51,6 @@ namespace Http2SampleApp options.Listen(IPAddress.Any, basePort + 5, listenOptions => { listenOptions.Protocols = HttpProtocols.Http2; - // listenOptions.UseConnectionLogging(); }); }) .UseContentRoot(Directory.GetCurrentDirectory()) diff --git a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs index 5d504b4fce..15035a81b4 100644 --- a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs +++ b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs @@ -608,6 +608,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 _clientSettings.ParseFrame(_incomingFrame); + var ackTask = _frameWriter.WriteSettingsAckAsync(); // Ack before we update the windows, they could send data immediately. + // This difference can be negative. var windowSizeDifference = (int)_clientSettings.InitialWindowSize - previousInitialWindowSize; @@ -625,7 +627,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 } } - return _frameWriter.WriteSettingsAckAsync(); + return ackTask; } catch (Http2SettingsParameterOutOfRangeException ex) { diff --git a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs index 497662a2e7..7bf017534b 100644 --- a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs +++ b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs @@ -2328,6 +2328,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests _clientSettings.InitialWindowSize += 1; await SendSettingsAsync(); + await ExpectAsync(Http2FrameType.SETTINGS, + withLength: 0, + withFlags: (byte)Http2SettingsFrameFlags.ACK, + withStreamId: 0); + await WaitForConnectionErrorAsync( ignoreNonGoAwayFrames: false, expectedLastStreamId: 1,