Skip to content

Commit

Permalink
Dispose socket after connection failure (#2287)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK authored Oct 3, 2023
1 parent 97f6fbd commit 207e806
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public async ValueTask<ConnectResult> TryConnectAsync(ConnectContext context)
}
catch (Exception ex)
{
// Socket is recreated every connect attempt. Explicitly dispose failed socket before next attempt.
socket.Dispose();

SocketConnectivitySubchannelTransportLog.ErrorConnectingSocket(_logger, _subchannel.Id, currentEndPoint, ex);

if (firstConnectionError == null)
Expand Down

0 comments on commit 207e806

Please sign in to comment.