diff --git a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs index d5237df322..2ccf688ca0 100644 --- a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs +++ b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs @@ -12,7 +12,6 @@ using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; using Microsoft.AspNetCore.Connections; -using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Internal; using Microsoft.AspNetCore.SignalR.Client.Internal; using Microsoft.AspNetCore.SignalR.Protocol; @@ -74,7 +73,7 @@ namespace Microsoft.AspNetCore.SignalR.Client /// Sending any message resets the timer to the start of the interval. /// public TimeSpan KeepAliveInterval { get; set; } = DefaultKeepAliveInterval; - + /// /// Gets or sets the timeout for the initial handshake. /// @@ -556,6 +555,9 @@ namespace Microsoft.AspNetCore.SignalR.Client private async Task<(bool close, Exception exception)> ProcessMessagesAsync(HubMessage message, ConnectionState connectionState) { + Log.ResettingKeepAliveTimer(_logger); + ResetTimeout(); + InvocationRequest irq; switch (message) { @@ -601,7 +603,7 @@ namespace Microsoft.AspNetCore.SignalR.Client } case PingMessage _: Log.ReceivedPing(_logger); - // Nothing to do on receipt of a ping. + // timeout is reset above, on receiving any message break; default: throw new InvalidOperationException($"Unexpected message type: {message.GetType().FullName}"); @@ -777,9 +779,6 @@ namespace Microsoft.AspNetCore.SignalR.Client } else if (!buffer.IsEmpty) { - Log.ResettingKeepAliveTimer(_logger); - ResetTimeout(); - Log.ProcessingMessage(_logger, buffer.Length); var close = false; diff --git a/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionContext.cs b/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionContext.cs index 6a076e3c19..768edbf132 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionContext.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionContext.cs @@ -7,7 +7,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO.Pipelines; -using System.Runtime.ExceptionServices; using System.Security.Claims; using System.Threading; using System.Threading.Tasks; @@ -489,7 +488,7 @@ namespace Microsoft.AspNetCore.SignalR Volatile.Write(ref _lastReceivedTimeStamp, DateTime.UtcNow.Ticks); } } - + private static void AbortConnection(object state) { var connection = (HubConnectionContext)state;