diff --git a/src/PepperDash.Core/Comm/GenericSshClient.cs b/src/PepperDash.Core/Comm/GenericSshClient.cs index 546a2a67..a758378f 100644 --- a/src/PepperDash.Core/Comm/GenericSshClient.cs +++ b/src/PepperDash.Core/Comm/GenericSshClient.cs @@ -228,14 +228,15 @@ namespace PepperDash.Core return; } + ConnectEnabled = true; + if (_isProgramStopping) { this.LogDebug("Skipping connect because program is stopping"); + ConnectEnabled = false; return; } - ConnectEnabled = true; - try { connectLock.Wait(); @@ -516,7 +517,7 @@ namespace PepperDash.Core this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim()); KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED); - if (AutoReconnect && ConnectEnabled && !_isProgramStopping) + if (ConnectEnabled && !_isProgramStopping) { StartReconnectTimer(); } @@ -552,7 +553,7 @@ namespace PepperDash.Core this.LogException(ex, "ObjectDisposedException sending {message}", ComTextHelper.GetEscapedText(bytes)); KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED); - if (AutoReconnect && ConnectEnabled && !_isProgramStopping) + if (ConnectEnabled && !_isProgramStopping) { StartReconnectTimer(); }