Skip to content

Commit

Permalink
Add on-demand connection specific handshake error (#410)
Browse files Browse the repository at this point in the history
* Add handshake error for on-demand connection

* correct log messages
  • Loading branch information
zackliu authored Feb 26, 2019
1 parent e2e1b18 commit af6709d
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,16 @@ private async Task<bool> 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;
}
}
Expand Down Expand Up @@ -603,6 +612,9 @@ private static class Log
private static readonly Action<ILogger, string, Exception> _unexpectedExceptionInStop =
LoggerMessage.Define<string>(LogLevel.Warning, new EventId(29, "UnexpectedExceptionInStop"), "Connection {ServiceConnectionId} got unexpected exception in StopAsync.");

private static readonly Action<ILogger, string, Exception> _onDemandConnectionHandshakeResponse =
LoggerMessage.Define<string>(LogLevel.Information, new EventId(30, "OnDemandConnectionHandshakeResponse"), "Service returned handshake response: {Message}");

public static void FailedToWrite(ILogger logger, Exception exception)
{
_failedToWrite(logger, exception);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit af6709d

Please sign in to comment.