I'm using scala-ssh 0.7.0 to download a file from a remote server.
The download itself seems to be successful (I can find the downloaded file). Here is the last part of the log output:
16:14:43.824 [main] TRACE net.schmizz.sshj.xfer.LoggingTransferListener -- transferred 100% of
log-file.txt
16:14:43.824 [main] INFO net.schmizz.sshj.common.StreamCopier -- 44.82421875 KiB transferred in 1.572 seconds (28.514134064885496 KiB/s) 16:14:43.825 [main] DEBUG net.schmizz.sshj.xfer.scp.SCPEngine -- Remote agrees transfer done 16:14:43.826 [main] DEBUG net.schmizz.sshj.xfer.scp.SCPEngine -- Signalling: Transfer done 16:14:43.826 [main] TRACE net.schmizz.sshj.transport.Encoder -- Encoding packet #10: 5e 00 00 00 00 00 00 00 01 00 16:14:43.826 [main] DEBUG net.schmizz.sshj.connection.channel.Window$Remote -- Consuming by 1 down to 2097148 16:14:44.220 [reader] TRACE net.schmizz.sshj.transport.Decoder -- Received packet #14: 62 00 00 00 00 00 00 00 0b 65 78 69 74 2d 73 74 61 74 75 73 00 00 00 00 00 16:14:44.221 [reader] TRACE net.schmizz.sshj.transport.TransportImpl -- Received packet CHANNEL_REQUEST 16:14:44.221 [reader] DEBUG net.schmizz.sshj.connection.channel.direct.SessionChannel -- Got chan request forexit-status
16:14:44.222 [reader] TRACE net.schmizz.sshj.transport.Decoder -- Received packet #15: 60 00 00 00 00 16:14:44.222 [reader] TRACE net.schmizz.sshj.transport.TransportImpl -- Received packet CHANNEL_EOF 16:14:44.222 [reader] DEBUG net.schmizz.sshj.connection.channel.direct.SessionChannel -- Got EOF 16:14:44.223 [reader] TRACE net.schmizz.sshj.transport.Decoder -- Received packet #16: 61 00 00 00 00 16:14:44.223 [reader] TRACE net.schmizz.sshj.transport.TransportImpl -- Received packet CHANNEL_CLOSE 16:14:44.223 [main] DEBUG net.schmizz.sshj.connection.channel.direct.SessionChannel -- Sending close 16:14:44.223 [reader] DEBUG net.schmizz.sshj.connection.channel.direct.SessionChannel -- Got close 16:14:44.224 [main] TRACE net.schmizz.sshj.transport.Encoder -- Encoding packet #11: 61 00 00 00 00 16:14:44.225 [main] DEBUG net.schmizz.concurrent.Promise -- Awaiting <> 16:14:44.225 [reader] DEBUG net.schmizz.sshj.connection.ConnectionImpl -- Forgettingsession
channel (#0) 16:14:44.225 [reader] DEBUG net.schmizz.concurrent.Promise -- Setting <> toSOME
My code is very simple:
import com.decodified.scalassh._
val sshClient = new SshClient(new HostConfig(login = PasswordLogin(userName, SimplePasswordProducer(password)), hostName))
sshClient.download(filePath, targetDirectory)
Now, although the download finishes successfully, and the application execution continues after the download command, the application itself doesn't exit.
Any ideas?
The implicit conversion to RichSshClient seems to be behind this. I avoided the implicit convertion to RichSshClient by creating a new class -- 'SshClientEnhanced' which extends SshClient with ScpTransferable. Invoking download method on an instance of SshClientEnhanced works fine.