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

Stuck at "Closing connection" state after upload file #20

Open
jerrycm opened this issue Nov 27, 2014 · 5 comments
Open

Stuck at "Closing connection" state after upload file #20

jerrycm opened this issue Nov 27, 2014 · 5 comments

Comments

@jerrycm
Copy link

jerrycm commented Nov 27, 2014

SSH("host", h) { client =>
        client.upload(file.getAbsolutePath, file.getName)
}

Here's output log.

11:09:44.452 [main] INFO  net.schmizz.sshj.common.SecurityUtils - BouncyCastle registration succeeded
11:09:44.490 [main] WARN  net.schmizz.sshj.DefaultConfig - Disabling high-strength ciphers: cipher strengths apparently limited by JCE policy
11:09:44.509 [main] INFO  com.decodified.scalassh.package$RichSshClient - Connecting to myhost.com:22 ...
11:09:44.557 [main] INFO  net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0_9_2
11:09:44.606 [main] INFO  net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
11:09:44.826 [main] INFO  com.decodified.scalassh.package$RichSshClient - Authenticating to myhost.com:22 using jerry.cm ...
11:09:45.326 [main] INFO  net.schmizz.sshj.connection.channel.direct.SessionChannel - Will request to exec `scp -t -r -p 'dummy.txt'`
11:09:45.473 [main] INFO  net.schmizz.sshj.common.StreamCopier - 0.0048828125 KiB transferred in 0.0 seconds (Infinity KiB/s)
11:09:45.653 [main] INFO  com.decodified.scalassh.SshClient - Closing connection to myhost.com:22 ...

The application doesn't close. It will be closed automatically if I just use client.exec. Should I close my application manually?

@joprice
Copy link
Contributor

joprice commented Dec 31, 2014

I have the same issue.

@sirthias
Copy link
Owner

sirthias commented Jan 2, 2015

Yeah, I had a similar issue myself but wasn't able to dig up the root cause at the time due to capacity constraints.

@stefri
Copy link
Contributor

stefri commented Jun 23, 2015

For me, this also applies to file downloads. When I execute the download test case, the connection hangs at close. Also the try-finally seems not necessary, since the connection is closed automatically.

@kostaskougios
Copy link

got same issue with client.upload(), a simple app never exits, probably due to this thread:

"reader" prio=10 tid=0x00007f70ac3bf000 nid=0x3fb7 runnable [0x00007f70a046d000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at net.schmizz.sshj.transport.Reader.run(Reader.java:50)

@kostaskougios
Copy link

Looks like this fixes it, ScpTransferable:

def fileTransfer[T](fun: SCPFileTransfer ⇒ T)(implicit listener: TransferListener = new LoggingTransferListener()): Validated[T] =
    authenticatedClient.right.flatMap { client ⇒
        protect("SCP file transfer failed") {
            val transfer = client.newSCPFileTransfer()
            transfer.setTransferListener(listener)
            try {
                fun(transfer)
            } finally {
                client.close()
            }
        }
    }

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

No branches or pull requests

5 participants