diff --git a/src/AlterNats/NatsConnection.cs b/src/AlterNats/NatsConnection.cs index d2608a020..ecbfec5d8 100644 --- a/src/AlterNats/NatsConnection.cs +++ b/src/AlterNats/NatsConnection.cs @@ -189,9 +189,10 @@ async ValueTask InitialConnectAsync() throw exception; } - // After INFO received, reconnect server list has been get. lock (gate) { + var url = currentConnectUri; + logger.LogInformation("Connect succeed, NATS {0}:{1}", url?.Host, url?.Port); this.ConnectionState = NatsConnectionState.Open; this.waitForOpenConnection.TrySetResult(); reconnectLoop = Task.Run(ReconnectLoopAsync); @@ -306,15 +307,15 @@ async Task ReconnectLoopAsync() if (socketWriter != null) { - await socketWriter.DisposeAsync(); + await socketWriter.DisposeAsync().ConfigureAwait(false); } if (socketReader != null) { - await socketReader.DisposeAsync(); + await socketReader.DisposeAsync().ConfigureAwait(false); } if (socket != null) { - await socket.DisposeAsync(); + await socket.DisposeAsync().ConfigureAwait(false); } socket = null; socketWriter = null; @@ -326,6 +327,7 @@ async Task ReconnectLoopAsync() lock (gate) { + logger.LogInformation("Connect succeed, NATS {0}:{1}", url.Host, url.Port); this.ConnectionState = NatsConnectionState.Open; this.waitForOpenConnection.TrySetResult(); reconnectLoop = Task.Run(ReconnectLoopAsync);