Trying and failing lots of things to fix SshClient. About to try making and destroying the entire client

This commit is contained in:
Heath Volmer
2016-12-06 15:41:49 -07:00
parent d1ce18fb64
commit d7613d2f52
8 changed files with 18 additions and 13 deletions

View File

@@ -222,7 +222,7 @@ namespace PepperDash.Core
if (TheStream != null)
{
TheStream.DataReceived -= Stream_DataReceived;
TheStream.ErrorOccurred += TheStream_ErrorOccurred;
TheStream.ErrorOccurred -= TheStream_ErrorOccurred;
}
TheStream = null;
}
@@ -242,10 +242,15 @@ namespace PepperDash.Core
try
{
Client.Connect();
if (Client.IsConnected)
{
Client.KeepAliveInterval = TimeSpan.FromSeconds(2);
Client.SendKeepAlive();
#warning We are getting past here with a false IsConnected when it appears to be connected
// Have to assume client is connected cause Client.IsConnected is busted in some cases
// All other conditions *should* error out...
//if (Client.IsConnected)
//{
//Client.KeepAliveInterval = TimeSpan.FromSeconds(2);
//Client.SendKeepAlive();
TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
TheStream.DataReceived += Stream_DataReceived;
TheStream.ErrorOccurred += TheStream_ErrorOccurred;
@@ -255,7 +260,7 @@ namespace PepperDash.Core
PreviousPassword = Password;
PreviousPort = Port;
PreviousUsername = Username;
}
//}
return; // Success will not pass here
}
catch (SshConnectionException e)
@@ -340,7 +345,7 @@ namespace PepperDash.Core
if (TheStream != null)
{
TheStream.DataReceived -= Stream_DataReceived;
TheStream.ErrorOccurred += TheStream_ErrorOccurred;
TheStream.ErrorOccurred -= TheStream_ErrorOccurred;
TheStream.Close();
TheStream.Dispose();
TheStream = null;
@@ -401,7 +406,7 @@ namespace PepperDash.Core
/// </summary>
void Client_ErrorOccurred(object sender, Crestron.SimplSharp.Ssh.Common.ExceptionEventArgs e)
{
if (e.Exception is SshConnectionException)
if (e.Exception is SshConnectionException || e.Exception is System.Net.Sockets.SocketException)
Debug.Console(1, this, "Disconnected by remote");
else
Debug.Console(1, this, "Unhandled SSH client error: {0}", e.Exception);

View File

@@ -2,6 +2,6 @@
<ControlSystem>
<Name>MC3 SSH</Name>
<Address>ssh 10.0.0.15</Address>
<ProgramSlot />
<Storage />
<ProgramSlot>Program01</ProgramSlot>
<Storage>Internal Flash</Storage>
</ControlSystem>

View File

@@ -10,8 +10,8 @@
<ArchiveName />
</RequiredInfo>
<OptionalInfo>
<CompiledOn>12/6/2016 9:36:24 AM</CompiledOn>
<CompilerRev>1.0.0.17290</CompilerRev>
<CompiledOn>12/6/2016 2:53:00 PM</CompiledOn>
<CompilerRev>1.0.0.26789</CompilerRev>
</OptionalInfo>
<Plugin>
<Version>Crestron.SIMPLSharp, Version=2.0.48.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version>

View File

@@ -1,4 +1,4 @@
MainAssembly=PepperDash_Core.dll:c8ab0c5c399e1cd7b79710c5a208e022
MainAssembly=PepperDash_Core.dll:3a5fe881bafa819e1046cf092f48b180
MainAssemblyMinFirmwareVersion=1.007.0017
MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e
ü