Skip to content

Commit

Permalink
more log
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Apr 12, 2022
1 parent a700f61 commit 6ca273a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/AlterNats/NatsConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 6ca273a

Please sign in to comment.