new SshClient Exception on Synology

Aug 13, 2013 at 5:09 PM
Edited Aug 13, 2013 at 7:12 PM
Hi,

Can you help me please ?

Client Win7
SHH on NAS Synology DS109+ enabled
Putty works (also localportforwarding)

code:
var connectionInfo = new PasswordConnectionInfo("192.168.2.66", "root", "password"); //NAS

using (SshClient client = new SshClient(connectionInfo))
 {
   client.Connect();  //Error starts here
 }            
output:

'SSHConnector.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\ONTWIKKELING\C-Sharp\SSHConnector\bin\Debug\SSHConnector.exe', Symbols loaded.
'SSHConnector.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\ONTWIKKELING\C-Sharp\SSHConnector\bin\Debug\Renci.SshNet.dll', Symbols loaded.
'SSHConnector.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SshNet.Logging Verbose: 1 : Initiating connect to '192.168.2.66:22'.
SshNet.Logging Verbose: 1 : Server version '2.0' on 'OpenSSH_5.8p1-hpn13v11'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
'SSHConnector.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'SSHConnector.vshost.exe' (Managed (v4.0.30319)): Loaded 'Anonymously Hosted DynamicMethods Assembly'
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeDhGroupExchangeRequest': 'SSH_MSG_KEX_DH_GEX_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeDhGroupExchangeGroup': 'SSH_MSG_KEX_DH_GEX_GROUP'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeDhGroupExchangeInit': 'SSH_MSG_KEX_DH_GEX_INIT'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeDhGroupExchangeReply': 'SSH_MSG_KEX_DH_GEX_REPLY'.
SshNet.Logging Verbose: 1 : SendMessage to server 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ServiceRequestMessage': 'SSH_MSG_SERVICE_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ServiceAcceptMessage': 'SSH_MSG_SERVICE_ACCEPT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'RequestMessageNone': 'SSH_MSG_USERAUTH_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'FailureMessage': 'SSH_MSG_USERAUTH_FAILURE'. ??????????
SshNet.Logging Verbose: 1 : SendMessage to server 'RequestMessagePassword': 'SSH_MSG_USERAUTH_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'SuccessMessage': 'SSH_MSG_USERAUTH_SUCCESS'.

A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'Renci.SshNet.Common.SshConnectionException' occurred in Renci.SshNet.dll

The thread '<No Name>' (0x1a28) has exited with code 0 (0x0).
Aug 13, 2013 at 5:46 PM
Whats the exception?
Where is the code where the exception occurs.
"Error starts here <<<" is not valid C-Sharp-Code ;)
Aug 13, 2013 at 7:11 PM
Sorry...

De exception start at
client.Connect();

error is:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'Renci.SshNet.Common.SshConnectionException' occurred in Renci.SshNet.dll

Thank you.
Aug 13, 2013 at 7:27 PM
Please give all informations of the exception. Message, stacktrace etc. ...
Aug 14, 2013 at 1:17 AM
I solved it, it's strange but I changed
using (SshClient client = new SshClient(connectionInfo))
to:
SshClient client = new SshClient(connectionInfo);
and now it works...

After that I had troubles with
 var fowardPort = new ForwardedPortLocal("localhost", 8500, "www.something.com", 80);
It didn't work, after spending hour's I changed (visual studio 2010) Build platform target from "ANY CPU" to "X86"
and now it works, yes...
I'm on Win7 X64.

Thank you
Aug 14, 2013 at 4:49 AM
It's not strange.
Connect() returns after it is done.

Your code was:
using (SshClient client = new SshClient(connectionInfo))
 {
   client.Connect();  //Error starts here
 }   
The client object is created, it gets connected and then everything is done and the using-block disposes the object.

Please be more specific with your problems, else it is impossible to help!
I don't think the forwarding does not work with AnyCpu. What "troubles" did you have?