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

View File

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

View File

@@ -10,8 +10,8 @@
<ArchiveName /> <ArchiveName />
</RequiredInfo> </RequiredInfo>
<OptionalInfo> <OptionalInfo>
<CompiledOn>12/6/2016 9:36:24 AM</CompiledOn> <CompiledOn>12/6/2016 2:53:00 PM</CompiledOn>
<CompilerRev>1.0.0.17290</CompilerRev> <CompilerRev>1.0.0.26789</CompilerRev>
</OptionalInfo> </OptionalInfo>
<Plugin> <Plugin>
<Version>Crestron.SIMPLSharp, Version=2.0.48.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version> <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 MainAssemblyMinFirmwareVersion=1.007.0017
MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e
ü ü