From 81918706b6da078fe334300633f35c7fc21d7801 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Tue, 23 Jan 2024 11:16:40 +0000 Subject: [PATCH] Disconnect timed out connects (#6594) --- src/Nethermind/Nethermind.Network/Rlpx/RlpxHost.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Nethermind/Nethermind.Network/Rlpx/RlpxHost.cs b/src/Nethermind/Nethermind.Network/Rlpx/RlpxHost.cs index 094faf98872..eec9422046d 100644 --- a/src/Nethermind/Nethermind.Network/Rlpx/RlpxHost.cs +++ b/src/Nethermind/Nethermind.Network/Rlpx/RlpxHost.cs @@ -181,6 +181,15 @@ public async Task ConnectAsync(Node node) if (firstTask != connectTask) { if (_logger.IsTrace) _logger.Trace($"|NetworkTrace| {node:s} OUT connection timed out"); + + _ = connectTask.ContinueWith(async c => + { + if (connectTask.IsCompletedSuccessfully) + { + await c.Result.DisconnectAsync(); + } + }); + throw new NetworkingException($"Failed to connect to {node:s} (timeout)", NetworkExceptionType.Timeout); }