Hi,
I am trying to connect to an external server using SFTP via an internal SOCKS proxy server. The connection works fine in WinSCP but I am getting error "_SOCKS5:Host unreacheable_" in my code.
I am using class __SftpClient__ instantiated with a __PasswordConnectionInfo__ using __ProxyType.Socks5__ as shown by the given constructor below:
public PasswordConnectionInfo(
string host,
int port,
string username,
string password,
ProxyTypes proxyType,
string proxyHost,
int proxyPort).
Debugging ssh.net source code, The error is being thrown after my machine sends the connection request to the Proxy and awaits a response at SocketReadByte() line below in class __Session.cs__:
// Send port
this.SocketWriteByte((byte)(this.ConnectionInfo.Port / 0xFF));
this.SocketWriteByte((byte)(this.ConnectionInfo.Port % 0xFF));
// Read Server SOCKS5 version
if (this.SocketReadByte() != 5) *** error is thrown here after about 2 minutes!
Using WireShark, I checked that my machine/Proxy handshake was successful, and the IP address of the external server is being looked up correctly. The bit I am not sure about here in the library source code above is the 2 lines where the port number is being specified. What is the use of "0xFF"?
_[field 6: network byte order port number, 2 bytes]._
I am having a suspucion about the Port number not being sent correctly!
Grateful if anyone can throw some ligth upon this or if someone had similar issues or if anyone had this working successfully.
Thank you.
I am trying to connect to an external server using SFTP via an internal SOCKS proxy server. The connection works fine in WinSCP but I am getting error "_SOCKS5:Host unreacheable_" in my code.
I am using class __SftpClient__ instantiated with a __PasswordConnectionInfo__ using __ProxyType.Socks5__ as shown by the given constructor below:
public PasswordConnectionInfo(
string host,
int port,
string username,
string password,
ProxyTypes proxyType,
string proxyHost,
int proxyPort).
Debugging ssh.net source code, The error is being thrown after my machine sends the connection request to the Proxy and awaits a response at SocketReadByte() line below in class __Session.cs__:
// Send port
this.SocketWriteByte((byte)(this.ConnectionInfo.Port / 0xFF));
this.SocketWriteByte((byte)(this.ConnectionInfo.Port % 0xFF));
// Read Server SOCKS5 version
if (this.SocketReadByte() != 5) *** error is thrown here after about 2 minutes!
Using WireShark, I checked that my machine/Proxy handshake was successful, and the IP address of the external server is being looked up correctly. The bit I am not sure about here in the library source code above is the 2 lines where the port number is being specified. What is the use of "0xFF"?
_[field 6: network byte order port number, 2 bytes]._
I am having a suspucion about the Port number not being sent correctly!
Grateful if anyone can throw some ligth upon this or if someone had similar issues or if anyone had this working successfully.
Thank you.