From 3df50e117a6953810b2d710443bc9dae2db83b68 Mon Sep 17 00:00:00 2001 From: jtalborough Date: Mon, 10 Feb 2025 14:35:22 -0500 Subject: [PATCH] fix: additional logging and kill client on IO exception --- .../Pepperdash Core/Comm/GenericSshClient.cs | 63 +++++++++++-------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs index f27a104..614ed1f 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs @@ -496,40 +496,49 @@ namespace PepperDash.Core /// public void SendText(string text) { - try - { - if (Client != null && TheStream != null && IsConnected) - { - if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, - this, - "Sending {0} characters of text: '{1}'", - text.Length, - ComTextHelper.GetDebugText(text)); + try + { + if (Client != null && TheStream != null && IsConnected) + { + if (StreamDebugging.TxStreamDebuggingIsEnabled) + Debug.Console(0, + this, + "Sending {0} characters of text: '{1}'", + text.Length, + ComTextHelper.GetDebugText(text)); - TheStream.Write(text); - TheStream.Flush(); - } - else - { - Debug.Console(1, this, "Client is null or disconnected. Cannot Send Text"); - } - } - catch (ObjectDisposedException ex) + TheStream.Write(text); + TheStream.Flush(); + } + else + { + Debug.Console(1, this, "Client is null or disconnected. Cannot Send Text"); + } + } + catch (ObjectDisposedException ex) { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Exception: {0}", ex.Message); Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Stack Trace: {0}", ex.StackTrace); - KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED); + KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED); + ReconnectTimer.Reset(); + } + catch (Crestron.SimplSharp.CrestronIO.IOException ex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Crestron.SimplSharp.CrestronIO.IOException: {0} -\n{1}\n", ex.Message, ex); + Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Crestron.SimplSharp.CrestronIO.IOException Stack Trace: {0}", ex.StackTrace); + Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Crestron.SimplSharp.CrestronIO.IOException Stream write failed"); + KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED); ReconnectTimer.Reset(); - } - catch (Exception ex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Exception: {0}", ex.Message); - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Stack Trace: {0}", ex.StackTrace); - Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stream write failed"); - } + } + catch (Exception ex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Exception: {0} -\n{1}\n", ex.Message, ex); + Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); + Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stream write failed"); + + } } ///