Hello guys,
im trying to connect through a proxy to my SSH server but i get an exception:
"__Renci.SshNet.Common.SshOperationTimeoutException: Socket read operation has time
d out
at Renci.SshNet.Session.SocketReadLine(String& response)
at Renci.SshNet.Session.ConnectHttp()
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at UAMT.MyClasses.RenciSSH..ctor() in D:\Project\MyClasses\RenciSSH.cs:line 36__".
In the Java Console i can see that it is connecting to Proxy but cant get connection to server. I placed the exe on a local pc and connected successfully to the SSH server without going through proxy. I tryed to connect with PuTTY using the same configuration (with proxy) and it worked fine. I also tryed another lib "Chilkat" and it worked fine (__without KeyAuthentification__) too but you have to buy a license to unlock the trial version and other libs dont support proxy functionality..... :(
the code im using:
ConnectionInfo connectionInfo = new ConnectionInfo("xx.xx.xx.xx", 22, "username", ProxyTypes.Http, "127.0.0.1", 18080, "", "", new PasswordAuthenticationMethod("username", "password"));
try
{
using (var ssh = new SshClient(connectionInfo))
{
ssh.Connect();
ssh.RunCommand("ls -l");
ssh.Disconnect();
}
}
catch (Exception ex)
{
Console.WriteLine();
}
Am i doing something wrong with ssh.net (maybe a flag that need to be set or something)?
Thanks in advance
killikax
Comments: ** Comment from web user: xboixed **
im trying to connect through a proxy to my SSH server but i get an exception:
"__Renci.SshNet.Common.SshOperationTimeoutException: Socket read operation has time
d out
at Renci.SshNet.Session.SocketReadLine(String& response)
at Renci.SshNet.Session.ConnectHttp()
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at UAMT.MyClasses.RenciSSH..ctor() in D:\Project\MyClasses\RenciSSH.cs:line 36__".
In the Java Console i can see that it is connecting to Proxy but cant get connection to server. I placed the exe on a local pc and connected successfully to the SSH server without going through proxy. I tryed to connect with PuTTY using the same configuration (with proxy) and it worked fine. I also tryed another lib "Chilkat" and it worked fine (__without KeyAuthentification__) too but you have to buy a license to unlock the trial version and other libs dont support proxy functionality..... :(
the code im using:
ConnectionInfo connectionInfo = new ConnectionInfo("xx.xx.xx.xx", 22, "username", ProxyTypes.Http, "127.0.0.1", 18080, "", "", new PasswordAuthenticationMethod("username", "password"));
try
{
using (var ssh = new SshClient(connectionInfo))
{
ssh.Connect();
ssh.RunCommand("ls -l");
ssh.Disconnect();
}
}
catch (Exception ex)
{
Console.WriteLine();
}
Am i doing something wrong with ssh.net (maybe a flag that need to be set or something)?
Thanks in advance
killikax
Comments: ** Comment from web user: xboixed **
Hi killikax,
I've had the same issue and was due to a bug in the Session.ConnectHttp method where there is an infinite loop (which is the reason of the TimeOut exception). Indeed, when dealing with the HTTP response, the status.OK should break the loop but it just breaks the select case instead and results in the mentioned infinite loop. The correction should be (in Session.ConnectHttp) :
```
switch (statusCode)
{
case HttpStatusCode.OK:
return; // instead of break;
default:
throw new ProxyException(string.Format("HTTP: Status code {0}, \"{1}\"", statusCode, statusCode));
}
```
Hope this solves your issue