From e74a3bd674fd9dc34bda9647a6a5e7039b750e95 Mon Sep 17 00:00:00 2001 From: Vyacheslav Brevnov Date: Mon, 3 Feb 2025 10:26:35 +0300 Subject: [PATCH 1/2] fix: UnhandledException: System.ObjectDisposedException. Error on thread pool #1588 --- src/Renci.SshNet/BaseClient.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Renci.SshNet/BaseClient.cs b/src/Renci.SshNet/BaseClient.cs index 876710db9..f095874e3 100644 --- a/src/Renci.SshNet/BaseClient.cs +++ b/src/Renci.SshNet/BaseClient.cs @@ -502,6 +502,14 @@ private void SendKeepAliveMessage() { _ = session.TrySendMessage(new IgnoreMessage()); } + catch (ObjectDisposedException) + { + // ignore + } + catch (Exception ex) + { + _logger.LogError(ex, "Error in TrySendMessage"); + } finally { Monitor.Exit(_keepAliveLock); From fe4d1fe010b1a9187559b35fcb52136fd7a3c029 Mon Sep 17 00:00:00 2001 From: Rob Hague Date: Tue, 4 Feb 2025 21:38:13 +0100 Subject: [PATCH 2/2] tweak message --- src/Renci.SshNet/BaseClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renci.SshNet/BaseClient.cs b/src/Renci.SshNet/BaseClient.cs index f095874e3..d855c7342 100644 --- a/src/Renci.SshNet/BaseClient.cs +++ b/src/Renci.SshNet/BaseClient.cs @@ -508,7 +508,7 @@ private void SendKeepAliveMessage() } catch (Exception ex) { - _logger.LogError(ex, "Error in TrySendMessage"); + _logger.LogError(ex, "Error sending keepalive message"); } finally {