TechTinkerer42 / j2ssh-fork

Automatically exported from code.google.com/p/j2ssh-fork
0 stars 0 forks source link

Basic SFTP client code fails #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

TransportProviderFactory calls bind() with the "host" as a parameter when 
attempting to use as a client, resulting in an exception.

java.net.BindException: Cannot assign requested address: bind
    at sun.nio.ch.Net.bind(Native Method)
    at sun.nio.ch.SocketChannelImpl.bind(Unknown Source)
    at sun.nio.ch.SocketAdaptor.bind(Unknown Source)
    at 
com.sshtools.j2ssh.net.TransportProviderFactory.connectTransportProvider
(TransportProviderFactory.java:67)
    at com.sshtools.j2ssh.SshClient.connect(SshClient.java:773)

Looks like this code is being modified for use as a server, as the bind() 
call is unnecessary for client usage.

Code to duplicate the error:

SshClient ssh = new SshClient();
ssh.connect("remote-host.mydomain.com", 22, new 
AlwaysAllowingConsoleKnownHostsKeyVerification());

Google AlwaysAllowingConsoleKnownHostsKeyVerification to find code for 
this class if necessary.

Original issue reported on code.google.com by soft.hor...@gmail.com on 23 Apr 2010 at 5:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've also had this issue. I'll try working around it in the morning and attach
sources if I find a solution.

Original comment by paul.pol...@googlemail.com on 13 May 2010 at 9:46

GoogleCodeExporter commented 9 years ago
I used bind(null) in order to bind the local socket to a free port and the local
address and replaced the original bind (that targets the destination server 
socket)
with socket().connect passing the original bind parameters.

The connection and authentication now complete but the client fails at 
initialize()
when it tries to start the SftpSubsystemClient

Original comment by paul.pol...@googlemail.com on 16 May 2010 at 7:26