diff --git a/src/Microsoft.Azure.SignalR.Common/ServiceConnections/ServiceConnectionBase.cs b/src/Microsoft.Azure.SignalR.Common/ServiceConnections/ServiceConnectionBase.cs index 3166eb17a..82433bbb1 100644 --- a/src/Microsoft.Azure.SignalR.Common/ServiceConnections/ServiceConnectionBase.cs +++ b/src/Microsoft.Azure.SignalR.Common/ServiceConnections/ServiceConnectionBase.cs @@ -308,7 +308,16 @@ private async Task ReceiveHandshakeResponseAsync(PipeReader input, Cancell } // Handshake error. Will stop reconnect. - Log.HandshakeError(_logger, handshakeResponse.ErrorMessage); + if (_connectionType == ServerConnectionType.OnDemand) + { + // Handshake errors on on-demand connections are acceptable. + Log.OnDemandConnectionHandshakeResponse(_logger, handshakeResponse.ErrorMessage); + } + else + { + Log.HandshakeError(_logger, handshakeResponse.ErrorMessage); + } + return false; } } @@ -603,6 +612,9 @@ private static class Log private static readonly Action _unexpectedExceptionInStop = LoggerMessage.Define(LogLevel.Warning, new EventId(29, "UnexpectedExceptionInStop"), "Connection {ServiceConnectionId} got unexpected exception in StopAsync."); + private static readonly Action _onDemandConnectionHandshakeResponse = + LoggerMessage.Define(LogLevel.Information, new EventId(30, "OnDemandConnectionHandshakeResponse"), "Service returned handshake response: {Message}"); + public static void FailedToWrite(ILogger logger, Exception exception) { _failedToWrite(logger, exception); @@ -730,6 +742,11 @@ public static void HandshakeError(ILogger logger, string error) _handshakeError(logger, error, null); } + public static void OnDemandConnectionHandshakeResponse(ILogger logger, string message) + { + _onDemandConnectionHandshakeResponse(logger, message, null); + } + public static void SentPing(ILogger logger) { _sentPing(logger, null);