Skip to content

The custom sftp server was blocked while processing ls #855

@xinghhhhhhh

Description

@xinghhhhhhh

description

I wrote an sftp server proxy using mina-sshd, and I found that the listener logging for open requests took a long time to process, sometimes blocking.

Log Description

One of my test logs showed a difference of about 20s.See attached sftp-2160-test-ls.log for the full log

2025-11-25 18:38:37.859 [sshd-SshClient[6c827e56]-nio2-thread-1] TRACE org.apache.sshd.common.io.nio2.Nio2Session - handleCompletedWriteCycle(Nio2Session[local=/0:0:0:0:0:0:0:0:53369, remote=/10.10.16.195:1234]) finished writing len=80 at cycle=18 after 536100 nanos
2025-11-25 18:38:52.862 [sshd-MySftpSubsystem-58008-thread-1] DEBUG org.example.sftpServerTest.SftpAuditRecorder - TEST LOG: Open file: /

Some information

Appears when the target device is a network device.
In 2.16.0, it doesn't block when I comment out the log output in the open method of SftpAuditRecorder.
In 2.13.2, log printing blocks even if you comment it out, and will always block.

public class SftpAuditRecorder implements SftpEventListener {

    private static final Log log = LogFactory.getLog(SftpAuditRecorder.class);

    @Override
    public void open(ServerSession session, String remoteHandle, Handle localHandle) throws IOException {
        Path path = localHandle.getFile();
        if (log.isDebugEnabled()) {
            log.debug( "TEST LOG: Open " + (Files.isDirectory(path) ? "dir: " : "file: ") + path);
        }
    }
}

attachment

sshd-sftp-2160-Test.zip

sftp-2160-test-ls.log

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions