From f12fd795ec5b4da67396da1bccd3bfd878f57b45 Mon Sep 17 00:00:00 2001 From: Jason Ginchereau Date: Fri, 14 Jul 2023 15:50:51 -1000 Subject: [PATCH] Add more tracing for client reconnect --- cs/src/Connections/TunnelClient.cs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cs/src/Connections/TunnelClient.cs b/cs/src/Connections/TunnelClient.cs index 41bec16a..8b284b85 100644 --- a/cs/src/Connections/TunnelClient.cs +++ b/cs/src/Connections/TunnelClient.cs @@ -281,20 +281,27 @@ private void OnForwardedPortAdded(PortForwardingService pfs, ForwardedPortEventA } } - for (int i = 0; i < disconnectedStreamsCount; i++) + if (disconnectedStreamsCount > 0) { - Task.Run(async () => + this.Trace.Verbose( + $"Reconnecting {disconnectedStreamsCount} stream(s) to forwarded port {port}"); + + for (int i = 0; i < disconnectedStreamsCount; i++) { - try - { - await pfs.ConnectToForwardedPortAsync(port.Value, CancellationToken.None); - } - catch (Exception ex) + Task.Run(async () => { - this.Trace.Warning( - $"Failed to reconnect to forwarded port {port}: {ex.Message}"); - } - }); + try + { + await pfs.ConnectToForwardedPortAsync(port.Value, CancellationToken.None); + this.Trace.Verbose($"Reconnected stream to forwarded port {port}"); + } + catch (Exception ex) + { + this.Trace.Warning( + $"Failed to reconnect to forwarded port {port}: {ex.Message}"); + } + }); + } } }