Log when closing connection due to timeout (#2722)

This commit is contained in:
BrennanConroy 2018-08-02 15:21:24 -07:00 committed by GitHub
parent 1358d5a07e
commit 90606338fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -502,6 +502,7 @@ namespace Microsoft.AspNetCore.SignalR
{
if (!_receivedMessageThisInterval)
{
Log.ClientTimeout(_logger, TimeSpan.FromTicks(_clientTimeoutInterval));
Abort();
}
@ -560,6 +561,9 @@ namespace Microsoft.AspNetCore.SignalR
private static readonly Action<ILogger, Exception> _abortFailed =
LoggerMessage.Define(LogLevel.Trace, new EventId(8, "AbortFailed"), "Abort callback failed.");
private static readonly Action<ILogger, int, Exception> _clientTimeout =
LoggerMessage.Define<int>(LogLevel.Debug, new EventId(9, "ClientTimeout"), "Client timeout ({ClientTimeout}ms) elapsed without receiving a message from the client. Closing connection.");
public static void HandshakeComplete(ILogger logger, string hubProtocol)
{
_handshakeComplete(logger, hubProtocol, null);
@ -599,6 +603,11 @@ namespace Microsoft.AspNetCore.SignalR
{
_abortFailed(logger, exception);
}
public static void ClientTimeout(ILogger logger, TimeSpan timeout)
{
_clientTimeout(logger, (int)timeout.TotalMilliseconds, null);
}
}
}
}