diff --git a/src/Microsoft.AspNetCore.Http.Connections.Client/Internal/WebSocketsTransport.cs b/src/Microsoft.AspNetCore.Http.Connections.Client/Internal/WebSocketsTransport.cs index c6ebeabce3..cfa225b46d 100644 --- a/src/Microsoft.AspNetCore.Http.Connections.Client/Internal/WebSocketsTransport.cs +++ b/src/Microsoft.AspNetCore.Http.Connections.Client/Internal/WebSocketsTransport.cs @@ -198,7 +198,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal while (true) { #if NETCOREAPP2_1 - // Do a 0 byte read so that idle connections don't allocate a buffer when waiting for a read var result = await socket.ReceiveAsync(Memory.Empty, CancellationToken.None); if (result.MessageType == WebSocketMessageType.Close) @@ -223,7 +222,8 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal // Exceptions are handled above where the send and receive tasks are being run. var receiveResult = await socket.ReceiveAsync(arraySegment, CancellationToken.None); - +#endif + // Need to check again for NetCoreApp2.1 because a close can happen between a 0-byte read and the actual read if (receiveResult.MessageType == WebSocketMessageType.Close) { Log.WebSocketClosed(_logger, _webSocket.CloseStatus); @@ -235,7 +235,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal return; } -#endif + Log.MessageReceived(_logger, receiveResult.MessageType, receiveResult.Count, receiveResult.EndOfMessage); _application.Output.Advance(receiveResult.Count); diff --git a/src/Microsoft.AspNetCore.Http.Connections/Internal/Transports/WebSocketsTransport.cs b/src/Microsoft.AspNetCore.Http.Connections/Internal/Transports/WebSocketsTransport.cs index b3c7126834..e77dbfe102 100644 --- a/src/Microsoft.AspNetCore.Http.Connections/Internal/Transports/WebSocketsTransport.cs +++ b/src/Microsoft.AspNetCore.Http.Connections/Internal/Transports/WebSocketsTransport.cs @@ -154,7 +154,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports var memory = _application.Output.GetMemory(); #if NETCOREAPP2_1 - // Because we checked the CloseStatus from the 0 byte read above, we don't need to check again after reading var receiveResult = await socket.ReceiveAsync(memory, CancellationToken.None); #else var isArray = MemoryMarshal.TryGetArray(memory, out var arraySegment); @@ -162,12 +161,13 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports // Exceptions are handled above where the send and receive tasks are being run. var receiveResult = await socket.ReceiveAsync(arraySegment, CancellationToken.None); - +#endif + // Need to check again for NetCoreApp2.1 because a close can happen between a 0-byte read and the actual read if (receiveResult.MessageType == WebSocketMessageType.Close) { return; } -#endif + Log.MessageReceived(_logger, receiveResult.MessageType, receiveResult.Count, receiveResult.EndOfMessage); _application.Output.Advance(receiveResult.Count); diff --git a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/VerifiableServerLoggedTest.cs b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/VerifiableServerLoggedTest.cs index 6f64b4bd81..ab0acf1abe 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/VerifiableServerLoggedTest.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/VerifiableServerLoggedTest.cs @@ -31,14 +31,6 @@ namespace Microsoft.AspNetCore.SignalR.Tests return true; } - // Suppress https://github.com/aspnet/SignalR/issues/2069 - if (writeContext.LoggerName == "Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionManager" && - writeContext.Message.StartsWith("Failed disposing connection") && - writeContext.Exception is WebSocketException) - { - return true; - } - return false; }; }