Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception by sftp.close() #173

Open
mfriendz opened this issue Jan 30, 2015 · 9 comments
Open

Exception by sftp.close() #173

mfriendz opened this issue Jan 30, 2015 · 9 comments

Comments

@mfriendz
Copy link

closing SFTPCient connection to a PSFTP server (www.psftp.de) dont seem to work as expected:

public static void main(String[] args) throws IOException {
    final SSHClient ssh = new SSHClient();
    ssh.addHostKeyVerifier(new PromiscuousVerifier());
    ssh.connect("psftp");
    ssh.authPassword("user", "pass");
    try {
        final SFTPClient sftp = ssh.newSFTPClient();
        try {
             sftp.put("/tmp/test.txt", "test.txt");
        } finally {
            sftp.close();      }
          } finally {
         ssh.disconnect();
    }
}
Jan 30, 2015 4:26:29 PM net.schmizz.sshj.common.SecurityUtils$BouncyCastleRegistration run
Information: BouncyCastle registration succeeded
Jan 30, 2015 4:26:29 PM net.schmizz.sshj.DefaultConfig initCipherFactories
Warnung: Disabling high-strength ciphers: cipher strengths apparently limited by JCE policy
Jan 30, 2015 4:26:29 PM net.schmizz.sshj.transport.TransportImpl init
Information: Client identity string: SSH-2.0-SSHJ_0_9_2
Jan 30, 2015 4:26:29 PM net.schmizz.sshj.transport.TransportImpl init
Information: Server identity string: SSH-2.0-PSFTPd. Secure FTP Server ready
Jan 30, 2015 4:26:29 PM net.schmizz.sshj.connection.channel.direct.SessionChannel startSubsystem
Information: Will request `sftp` subsystem
Jan 30, 2015 4:26:29 PM net.schmizz.sshj.transport.TransportImpl die
Schwerwiegend: Dying because - {}
net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
    at net.schmizz.sshj.transport.Reader.run(Reader.java:59)

Jan 30, 2015 4:26:29 PM net.schmizz.sshj.transport.TransportImpl$1 notifyDisconnect
Information: Disconnected - UNKNOWN
Jan 30, 2015 4:26:29 PM net.schmizz.concurrent.Promise tryRetrieve
Schwerwiegend: <<chan#0 / close>> woke to: net.schmizz.sshj.connection.ConnectionException: Broken transport; encountered EOF
Jan 30, 2015 4:26:29 PM net.schmizz.sshj.transport.TransportImpl$1 notifyDisconnect
Information: Disconnected - BY_APPLICATION
Exception in thread "main" net.schmizz.sshj.connection.ConnectionException: Broken transport; encountered EOF
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:32)
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:1)
    at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
    at net.schmizz.concurrent.Event.deliverError(Event.java:72)
    at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(ErrorDeliveryUtil.java:34)
    at net.schmizz.sshj.connection.channel.AbstractChannel.notifyError(AbstractChannel.java:218)
    at net.schmizz.sshj.connection.channel.direct.SessionChannel.notifyError(SessionChannel.java:229)
    at net.schmizz.sshj.common.ErrorNotifiable$Util.alertAll(ErrorNotifiable.java:35)
    at net.schmizz.sshj.connection.ConnectionImpl.notifyError(ConnectionImpl.java:262)
    at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:588)
    at net.schmizz.sshj.transport.Reader.run(Reader.java:67)
Caused by: net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
    at net.schmizz.sshj.transport.Reader.run(Reader.java:59)

If you only disconnect() without close() everything works fine...
This seems to be a PSFTP server issue only??

@hierynomus
Copy link
Owner

Hi @mfriendz,

Which version of SSHJ did you use to reproduce this? I've added a test (https://github.com/hierynomus/sshj/blob/master/src/test/java/com/hierynomus/sshj/sftp/SFTPClientTest.java) which tries this with Apache Mina, and there it at least does not occur.

@hierynomus
Copy link
Owner

@mfriendz I know this is a somewhat older issue, but would you be able to generate more detailed logging?

Prefer to set these loggers in logback.xml

<logger name="net.schmizz.sshj" level="debug"/>
<logger name="net.schmizz.sshj.transport" level="trace" />

@jkbaird
Copy link

jkbaird commented Jul 20, 2016

Encountered an issue that looks the same while running version 0.16.0. The issue is reproducible and more detailed logging is attached as requested.
sshjAssertion.txt

@hierynomus
Copy link
Owner

Thx @jkbaird I will have a look.

@hierynomus
Copy link
Owner

Just to get this straight, you were running a parallell process against 2 different SSH servers? (OpenSSH 5.3 and Adtran 4.31)

@jkbaird
Copy link

jkbaird commented Jul 20, 2016

Yes. That's correct. Connecting to two different servers in parallel process.

@JD557
Copy link

JD557 commented Aug 18, 2016

I believe that I'm also having this problem (connections dying with net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF even if I call close()).

I'm connecting to a single SFTP server, but with 4 different connections (each one downloading a different file).

This happened to me with version 0.15.0. I'm upgrading today to 0.17.2, so I'll say something if the problem goes away.

@tripexito
Copy link

I've been using SSHJ v0.20.0 to connect using sftp to freeFTPd and I'm getting the same Exception. I've realized that it doesn't work if try to upload any file to FTP server (reading files works fine). Even if I comment the close/disconnect instruction. Please give anyone can give me some approach how to solve this. Thanks in advance.

@renejahn
Copy link

renejahn commented Aug 6, 2018

Running into the same problem, while everything seems to work (v0.24.0). Are there any plans to fix this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants