[ 
https://issues.apache.org/jira/browse/SSHD-776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16192661#comment-16192661
 ] 

Fulvio Cavarretta edited comment on SSHD-776 at 10/5/17 9:26 AM:
-----------------------------------------------------------------

Hi [~lgoldstein], 
we will try to extract the client sample code (which is using a third party ssh 
library, not Apache SSHD client), but It' not very easy since it's spread 
inside a complex application.
I fully agree with you that the {{setWritten}} approach is not the right way to 
do it, but we did to see the effect (and, as far as now, it seems it's working 
fine)
Today we have reapeted the test using 1.7.0-SNAPSHOT taken from master branch 
(see [^dmzagent-1.7.0-snapshot.trc]).
1) We encountered the same problem {{channelEof}} also for 
{{AbstractConnectionService.channelWindowAdjust}} that we had to change 
accordingly as:

{code}
    /**
     * Process a window adjust packet on a channel
     *
     * @param buffer the buffer containing the window adjustment parameters
     * @throws IOException if an error occurs
     */
    public void channelWindowAdjust(Buffer buffer) throws IOException {
        try {
            // Do not use getChannel to avoid the session being closed
            // if receiving the SSH_MSG_CHANNEL_WINDOW_ADJUST on an already 
closed channel
            int recipient = buffer.getInt();
            Channel channel = channels.get(recipient);
            if (channel != null) {
                channel.handleWindowAdjust(buffer);
            } else {
                log.warn("Received SSH_MSG_CHANNEL_WINDOW_ADJUST on unknown 
channel " + recipient);
            }
        } catch (SshException e) {
            if (log.isDebugEnabled()) {
                log.debug("channelWindowAdjust {} error: {}", 
e.getClass().getSimpleName(), e.getMessage());
            }
        }
    }
{code}


We also added a trace in the {{Nio2Session.doCloseImmediately}} just before 
{{future.setException(new WriteAbortedException("Write request aborted due to 
immediate session close", null));}} to better track the failure.

2) The result of our analisys is that the root cause of the whole session 
disconnection happens when the connection to an external FTP server (data 
channel) is closed (channel {{[id=55, recipient=5]}}

{code}
2017-10-05 10:36:12,743 ERROR [.63:39488]]-thread-1] 
[Nio2Session.doCloseImmediately] Error while closing 
Nio2Session[local=/192.168.50.97:58724, remote=/192.168.2.107:60334] - 
WriteAbortedException
{code}

Like during the {{connector.close(true);}} scheduled duting 
{{closeImmediately0}} call, a write was still pending (maybe the one triggered 
by {{super.close(true);}}




was (Author: fcava):
Hi [~lgoldstein], 
we will try to extract the client sample code (which is using a third party ssh 
library, not Apache SSHD client), but It' not very easy since it's spread 
inside a complex application.
I fully agree with you that the {{setWritten}} approach is not the right way to 
do it, but we did to see the effect (and, as far as now, it seems it's working 
fine)
Today we have reapeted the test using 1.7.0-SNAPSHOT taken from master branch 
(see [^dmzagent-1.7.0-snapshot.trc]).
1) We encountered the same problem {{channelEof}} also for 
{{AbstractConnectionService.channelWindowAdjust}} that we had to change 
accordingly as:

{code}
    /**
     * Process a window adjust packet on a channel
     *
     * @param buffer the buffer containing the window adjustment parameters
     * @throws IOException if an error occurs
     */
    public void channelWindowAdjust(Buffer buffer) throws IOException {
        try {
            // Do not use getChannel to avoid the session being closed
            // if receiving the SSH_MSG_CHANNEL_WINDOW_ADJUST on an already 
closed channel
            int recipient = buffer.getInt();
            Channel channel = channels.get(recipient);
            if (channel != null) {
                channel.handleWindowAdjust(buffer);
            } else {
                log.warn("Received SSH_MSG_CHANNEL_WINDOW_ADJUST on unknown 
channel " + recipient);
            }
        } catch (SshException e) {
            if (log.isDebugEnabled()) {
                log.debug("channelWindowAdjust {} error: {}", 
e.getClass().getSimpleName(), e.getMessage());
            }
        }
    }
{code}


We also added a trace in the {{Nio2Session.doCloseImmediately}} just before 
{{future.setException(new WriteAbortedException("Write request aborted due to 
immediate session close", null));}} to better track the failure.

2) The result of our analisys is that the root cause of the whole session 
disconnection happens when the connection to an external FTP server (data 
channel) is closed (channel {{[id=55, recipient=5]}}

{code}
2017-10-05 10:36:12,743 ERROR [.63:39488]]-thread-1] 
[Nio2Session.doCloseImmediately] Error while closing 
Nio2Session[local=/192.168.50.97:58724, remote=/192.168.2.107:60334] - 
WriteAbortedException
{code}

Like during the {{connector.close(true);}} scheduled duting 
{{closeImmediately0}} call a write whas still pending (maybe the one triggered 
by {{super.close(true);}}



> SSHD local port forwarding close session unexpectedly
> -----------------------------------------------------
>
>                 Key: SSHD-776
>                 URL: https://issues.apache.org/jira/browse/SSHD-776
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>            Reporter: Fulvio Cavarretta
>            Assignee: Goldstein Lyor
>              Labels: channel, eof, forwarding, sshd
>         Attachments: dmzagent-1.7.0-snapshot.trc, dmzagent.trc, 
> dmzagent.trc.2, dmzagent-WriteAbortException.trc
>
>
> Apache SSHD used in local port forwarding mode.
> A client is connecting to a remote FTP server through Apache SSHD via a 
> custom software.
> When a new logical channel inside a single SSHD session get an IO error (e.g. 
> the remote destination close the connection suddenly, the whole session is 
> shut down causing all other logical channel to be closed (see line 8861of 
> attached trace file).
> It seems like the _exceptionCaught_ mathod should not be called in this case



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to