mardi 21 avril 2015

mina "Discarding output packet because channel is being closed" missing command output

We use Mina sshd client to connect to Linux based server. It looks like when we get the command SSH_MSG_CHANNEL_DATA along with the Received SSH_MSG_CHANNEL_EOF, Mina will not put the data into the output buffer and will log: "ChannelExec - Discarding output packet because channel is being closed"

Here is my sample code and Mina debug.

Is This a bug our am I using Mina async wrong?

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

Aucun commentaire:

Enregistrer un commentaire