You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Goldstein Lyor (JIRA)" <ji...@apache.org> on 2016/11/08 17:47:58 UTC

[jira] [Commented] (SSHD-711) Apache hangs sending file

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

Goldstein Lyor commented on SSHD-711:
-------------------------------------

An initial look at the "bad" log does not show anything out of the ordinary. Please try the recently release version 1.3 and see if this still occurs. As far as writing data to the same channel from several threads - it *might* work, but I would strongly recommend against it. Basically, the code for "sending" a file should open an SFTP connection and use it to upload/download the file. If another thread wants to upload/download a file to the same server then I strongly recommend creating a *new* {{SftpClient}} instance. *Note:* this does not require opening a new session just a new channel (so relatively cheap...):
{code:java}
ClientSession session = establishSSHSessionWithServer();
// 1st thread
new Thread(() -> {
    try (SftpClient sftp = session.createSftpClient()) {
           ...use sftp session to access files...
    }
}).start();

// 2nd thread - uses the SAME session but a different SFTP channel instance
new Thread(() -> {
    try (SftpClient sftp = session.createSftpClient()) {
           ...use sftp session to access files...
    }
}).start();
{code}

> Apache hangs sending file
> -------------------------
>
>                 Key: SSHD-711
>                 URL: https://issues.apache.org/jira/browse/SSHD-711
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 1.1.0
>            Reporter: Roger Hart
>            Priority: Minor
>         Attachments: SSHDbad.log, SSHDgood.log
>
>
> We're running 1.1.0 but I get the same problem with 1.2.0. When sending a file to a particular server we have problems on some machines but not others. I've attached a DEBUG log for a "good" machine and a "bad" machine.  For the "bad" machine, the system hangs midway through sending the file. Here are the final log entries.
> My theory is that "normally" you see a "Writing X bytes" message, followed by a "Finished writing" message, followed by a "Read Y bytes" message. But on the "bad" machine there seems to be 2 "Write" messages before the hang. I think this is because there are 2 threads putting a write request in the write queue and both are written out to the socket. I'm wondering if this can cause the max packet size specified in the SSH_MSG_CHANNEL_OPEN_CONFIRMATION message to be exceeded. The "good" machine has fewer threads than the "bad" machine, and we've also observed that a smaller files is less likely to hit the problem.
> Do you think this theory is valid?
> Thanks,
> Roger
> 10:29:22.448 7-Nov-16 -0800 | (lient.channel.ChannelSubsystem) handleData(ChannelSubsystem[id=0, recipient=0]-ClientSessionImpl[USER@/X.X.X.X:22][sftp]) SSH_MSG_CHANNEL_DATA len=19
> 10:29:22.450 7-Nov-16 -0800 | (che.sshd.common.channel.Window) waitForSpace(ChannelSubsystem[id=0, recipient=0]-ClientSessionImpl[USER@/X.X.X.X:22][sftp]: client remote window) available: 1073741779
> 10:29:22.450 7-Nov-16 -0800 | (che.sshd.common.channel.Window) waitAndConsume(ChannelSubsystem[id=0, recipient=0]-ClientSessionImpl[USER@/X.X.X.X:22][sftp]: client remote window) - requested=32768, available=1073741779
> 10:29:22.463 7-Nov-16 -0800 | (shd.common.io.nio2.Nio2Session) Writing 32820 bytes
> 10:29:22.464 7-Nov-16 -0800 | (che.sshd.common.channel.Window) waitForSpace(ChannelSubsystem[id=0, recipient=0]-ClientSessionImpl[USER@/X.X.X.X:22][sftp]: client remote window) available: 1073709011
> 10:29:22.464 7-Nov-16 -0800 | (che.sshd.common.channel.Window) waitAndConsume(ChannelSubsystem[id=0, recipient=0]-ClientSessionImpl[USER@/X.X.X.X:22][sftp]: client remote window) - requested=31, available=1073709011
> 10:29:22.464 7-Nov-16 -0800 | (shd.common.io.nio2.Nio2Session) Writing 84 bytes
> 10:29:22.534 7-Nov-16 -0800 | (shd.common.io.nio2.Nio2Session) Finished writing
> 10:29:22.534 7-Nov-16 -0800 | (shd.common.io.nio2.Nio2Session) Finished writing



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)