使用 scala-ssh 下载文件后应用程序不会退出

Application won't exit after downloading a file with scala-ssh

我正在使用 scala-ssh 0.7.0 从远程服务器下载文件。

下载本身似乎是成功的(我可以找到下载的文件)。这是日志输出的最后一部分:

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 for exit-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 -- Forgetting session channel (#0) 16:14:44.225 [reader] DEBUG net.schmizz.concurrent.Promise -- Setting <> to SOME

我的代码很简单:

import com.decodified.scalassh._

val sshClient = new SshClient(new HostConfig(login = PasswordLogin(userName, SimplePasswordProducer(password)), hostName))


sshClient.download(filePath, targetDirectory)

现在,虽然下载成功完成,并且应用程序在下载命令后继续执行,但应用程序本身并没有退出。

有什么想法吗?

到 RichSshClient 的隐式转换似乎是这背后的原因。 我通过创建一个新的 class -- 'SshClientEnhanced' 来避免隐式转换为 RichSshClient,它使用 ScpTransferable 扩展 SshClient。在 SshClientEnhanced 实例上调用下载方法工作正常。