Skip to content

Commit 207e806

Browse files
authored
Dispose socket after connection failure (#2287)
1 parent 97f6fbd commit 207e806

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Grpc.Net.Client/Balancer/Internal/SocketConnectivitySubchannelTransport.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ public async ValueTask<ConnectResult> TryConnectAsync(ConnectContext context)
190190
}
191191
catch (Exception ex)
192192
{
193+
// Socket is recreated every connect attempt. Explicitly dispose failed socket before next attempt.
194+
socket.Dispose();
195+
193196
SocketConnectivitySubchannelTransportLog.ErrorConnectingSocket(_logger, _subchannel.Id, currentEndPoint, ex);
194197

195198
if (firstConnectionError == null)

0 commit comments

Comments
 (0)