Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/NATS.Client.Core/Internal/NatsReadProtocolProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ await _connection.PublishToClientHandlersAsync(subject, replyTo, sid, headerSlic
}
catch (SocketClosedException e)
{
_logger.LogDebug(NatsLogEvents.Protocol, e, "Socket closed during read loop");
_waitForInfoSignal.TrySetException(e);
_waitForPongOrErrorSignal.TrySetException(e);
return;
}
catch (Exception ex)
Expand Down
12 changes: 11 additions & 1 deletion src/NATS.Client.Core/NatsConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,17 @@ private async ValueTask SetupReaderWriterAsync(bool reconnect)
}

// receive COMMAND response (PONG or ERROR)
await waitForPongOrErrorSignal.Task.ConfigureAwait(false);
try
{
await waitForPongOrErrorSignal.Task
.WaitAsync(Opts.ConnectTimeout)
.ConfigureAwait(false);
}
catch (TimeoutException)
{
_logger.LogDebug(NatsLogEvents.Connection, "Timeout waiting for initial pong");
throw;
}

if (reconnectTask != null)
{
Expand Down