Skip to content

Commit 880a68b

Browse files
authored
Merge pull request #189 from PepperDash/ssh-fix
Update some exception messages to not print exception
2 parents ab61b26 + 8ace195 commit 880a68b

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/Comm/GenericSshClient.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void Connect()
251251
try
252252
{
253253
Client.Connect();
254-
TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
254+
TheStream = Client.CreateShellStream("PDTShell", 0, 0, 0, 0, 65534);
255255
if (TheStream.DataAvailable)
256256
{
257257
// empty the buffer if there is data
@@ -269,18 +269,17 @@ public void Connect()
269269

270270
if (ie is SocketException)
271271
{
272-
this.LogException(ie, "CONNECTION failure: Cannot reach host, ({1})", Key, ie.Message);
272+
this.LogException(ie, "CONNECTION failure: Cannot reach host");
273273
}
274274

275275
if (ie is System.Net.Sockets.SocketException socketException)
276276
{
277-
this.LogException(ie, "'{0}' Connection failure: Cannot reach host '{1}' on port {2}, ({3})",
278-
Key, Hostname, Port, ie.GetType());
277+
this.LogException(ie, "Connection failure: Cannot reach {host} on {port}",
278+
Hostname, Port);
279279
}
280280
if (ie is SshAuthenticationException)
281281
{
282-
this.LogException(ie, "Authentication failure for username '{0}', ({1})", this,
283-
Username, ie.Message);
282+
this.LogException(ie, "Authentication failure for username {userName}", Username);
284283
}
285284
else
286285
this.LogException(ie, "Error on connect");
@@ -289,7 +288,7 @@ public void Connect()
289288
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
290289
if (AutoReconnect)
291290
{
292-
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
291+
this.LogDebug("Checking autoreconnect: {autoReconnect}, {autoReconnectInterval}ms", AutoReconnect, AutoReconnectIntervalMs);
293292
ReconnectTimer.Reset(AutoReconnectIntervalMs);
294293
}
295294
}
@@ -499,14 +498,14 @@ public void SendText(string text)
499498
}
500499
catch (ObjectDisposedException ex)
501500
{
502-
this.LogException(ex, "ObjectDisposedException sending {message}", text);
501+
this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim());
503502

504503
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
505504
ReconnectTimer.Reset();
506505
}
507506
catch (Exception ex)
508507
{
509-
this.LogException(ex, "Exception sending text: {message}", text);
508+
this.LogException(ex, "Exception sending text: '{message}'", text);
510509
}
511510
}
512511

0 commit comments

Comments
 (0)