我们使用 Mina sshd 客户端连接到基于 Linux 的服务器。看起来当我们得到命令 SSH_MSG_CHANNEL_DATA 以及 Received SSH_MSG_CHANNEL_EOF 时,Mina 不会将数据放入输出缓冲区并会记录:“ChannelExec - 丢弃输出数据包,因为通道正在关闭”
这是我的示例代码和 Mina 调试。
这是我们使用 Mina 异步错误的错误吗?
val channel: ChannelExec = clientSession.createExecChannel(cmd)
channel.setupSensibleDefaultPty()
channel.setUsePty(true)
channel.setStreaming(ClientChannel.Streaming.Async)
val bais: ByteArrayInputStream = new ByteArrayInputStream(Array[Byte]())
channel.setIn(bais)
val openFuture = channel.open()
val baosOut: ByteArrayOutputStream = new ByteArrayOutputStream()
openFuture.addListener(new SshFutureListener[OpenFuture] {
override def operationComplete(future: OpenFuture): Unit = {
channel.getAsyncOut.read(new Buffer).addListener(new SshFutureListener[IoReadFuture] {
def operationComplete(future: IoReadFuture) {
readBuffer(channel, future, channel.getAsyncOut, baosOut, this)
}
})
}
})
openFuture.await(connectionConfig.maxConnTime)
DEBUG Nio2Session - Read 244 bytes
DEBUG ChannelExec - Received SSH_MSG_CHANNEL_WINDOW_ADJUST on channel ChannelExec[id=153, recipient=0]
DEBUG Window - Increase client remote window by 2097152 up to 2097152
DEBUG ChannelExec - Received SSH_MSG_CHANNEL_DATA on channel ChannelExec[id=153, recipient=0]
DEBUG ChannelExec - Received SSH_MSG_CHANNEL_EOF on channel ChannelExec[id=153, recipient=0]
DEBUG ChannelExec - Received SSH_MSG_CHANNEL_REQUEST exit-status on channel ChannelExec[id=153, recipient=0] (wantReply false)
DEBUG ChannelExec - Received SSH_MSG_CHANNEL_CLOSE on channel ChannelExec[id=153, recipient=0]
DEBUG ChannelExec - Closing ChannelExec[id=153, recipient=0] gracefully
DEBUG ChannelSession$1 - Closing ChannelAsyncOutputStream[ChannelExec[id=153, recipient=0]] gracefully
DEBUG ChannelExec - Send SSH_MSG_CHANNEL_EOF on channel ChannelExec[id=153, recipient=0]
DEBUG ChannelExec - Discarding output packet because channel is being closed
DEBUG ChannelSession$1 - ChannelAsyncOutputStream[ChannelExec[id=153, recipient=0]] closed
DEBUG ChannelAsyncInputStream - Closing ChannelAsyncInputStream[ChannelExec[id=153, recipient=0]] gracefully
DEBUG ChannelAsyncInputStream - ChannelAsyncInputStream[ChannelExec[id=153, recipient=0]] closed
DEBUG ChannelAsyncInputStream - Closing ChannelAsyncInputStream[ChannelExec[id=153, recipient=0]] gracefully
DEBUG ChannelAsyncInputStream - ChannelAsyncInputStream[ChannelExec[id=153, recipient=0]] closed
DEBUG ChannelExec - Send SSH_MSG_CHANNEL_CLOSE on channel ChannelExec[id=153, recipient=0]
DEBUG Nio2Session - Writing 52 bytes
DEBUG Nio2Session - Finished writing
DEBUG ChannelExec - Message SSH_MSG_CHANNEL_CLOSE written on channel ChannelExec[id=153, recipient=0]
DEBUG ChannelSession$1 - ChannelAsyncOutputStream[ChannelExec[id=153, recipient=0]] is already closed
DEBUG ChannelAsyncInputStream - ChannelAsyncInputStream[ChannelExec[id=153, recipient=0]] is already closed
DEBUG ChannelAsyncInputStream - ChannelAsyncInputStream[ChannelExec[id=153, recipient=0]] is already closed
DEBUG ChannelExec - ChannelExec[id=153, recipient=0] closed