fix: handle Renci timeout exception

This commit is contained in:
Andrew Welker
2025-02-19 16:40:25 -06:00
parent 5908e67055
commit a60a277e49

View File

@@ -269,13 +269,18 @@ namespace PepperDash.Core
var errorLogLevel = DisconnectLogged == true ? Debug.ErrorLogLevel.None : Debug.ErrorLogLevel.Error; var errorLogLevel = DisconnectLogged == true ? Debug.ErrorLogLevel.None : Debug.ErrorLogLevel.Error;
if (ie is SocketException) if (ie is SocketException)
this.LogException(ie, "'{0}' CONNECTION failure: Cannot reach host, ({1})", Key, ie.Message); {
else if (ie is System.Net.Sockets.SocketException) this.LogException(ie, "CONNECTION failure: Cannot reach host, ({1})", Key, ie.Message);
}
if (ie is System.Net.Sockets.SocketException socketException)
{
this.LogException(ie, "'{0}' Connection failure: Cannot reach host '{1}' on port {2}, ({3})", this.LogException(ie, "'{0}' Connection failure: Cannot reach host '{1}' on port {2}, ({3})",
Key, Hostname, Port, ie.GetType()); Key, Hostname, Port, ie.GetType());
else if (ie is SshAuthenticationException) }
if (ie is SshAuthenticationException)
{ {
this.LogException(ie, "Authentication failure for username '{0}', ({1})",this, this.LogException(ie, "Authentication failure for username '{0}', ({1})", this,
Username, ie.Message); Username, ie.Message);
} }
else else
@@ -289,6 +294,18 @@ namespace PepperDash.Core
ReconnectTimer.Reset(AutoReconnectIntervalMs); ReconnectTimer.Reset(AutoReconnectIntervalMs);
} }
} }
catch(SshOperationTimeoutException ex)
{
this.LogWarning("Connection attempt timed out: {message}", ex.Message);
DisconnectLogged = true;
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
if (AutoReconnect)
{
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
ReconnectTimer.Reset(AutoReconnectIntervalMs);
}
}
catch (Exception e) catch (Exception e)
{ {
var errorLogLevel = DisconnectLogged == true ? Debug.ErrorLogLevel.None : Debug.ErrorLogLevel.Error; var errorLogLevel = DisconnectLogged == true ? Debug.ErrorLogLevel.None : Debug.ErrorLogLevel.Error;