Ticket #159 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

libssh2 takes long time to disconnect from CoreFTP's SFTP service

Reported by: qxu Owned by: stuge
Priority: normal Milestone: 1.2.5
Component: protocol Version: 1.2.4
Keywords: coreftp server idle timeout Cc:
Blocked By: Blocks:

Description

  1. Download CoreFTP server from http://www.coreftp.com/server/. Install it on a Windows platform, and set up an SFTP server. Start the service, with the default idle timeout setting as 600 seconds.
  1. Download the latest libssh2 source package, say, libssh2-1.2.4.tar.gz into a Unix/Linux? box.
  1. Compile it with debug option enabled, and you will get some binaries in "libssh2-1.2.4/example".
  1. In the above path, type the command "./sftpdir <coreftp_sftp_server_ip_address> <username> <password> <directory_to_be_listed>".
  1. Notice that the session will be finished after around 10 mins. This is unbearable.
  1. Even if the server's idle timeout value is reduced to 1 second, the sftpdir command will still take around 5 to 6 seconds to finish.
  1. FileZilla? and WinSCP have the same problem.

Attachments

sftpdir_idle_timeout.zip (49.0 KB) - added by qxu 2 years ago.
sftpdir_idle_timeout_1_sec.log (79.0 KB) - added by stuge 2 years ago.
libssh2 trace with idle timeout on server set to 1 second
sftpdir_idle_timeout_600_sec.log (82.0 KB) - added by stuge 2 years ago.
libssh2 trace with idle timeout on server set to 10 minutes
0001-Send-and-wait-for-channel-EOF-before-sending-SSH_MSG.patch (1.1 KB) - added by stuge 2 years ago.
Possible fix for this bug, please test it with the CoreFTP server

Download all attachments as: .zip

Change History

Changed 2 years ago by qxu

Changed 2 years ago by stuge

libssh2 trace with idle timeout on server set to 1 second

Changed 2 years ago by stuge

libssh2 trace with idle timeout on server set to 10 minutes

comment:1 Changed 2 years ago by stuge

  • Owner set to stuge
  • Status changed from new to accepted

Changed 2 years ago by stuge

Possible fix for this bug, please test it with the CoreFTP server

comment:2 Changed 2 years ago by stuge

Comparing libssh2 behavior with OpenSSH I discovered that libssh2 sends SSH_MSG_CHANNEL_CLOSE without sending SSH_MSG_CHANNEL_EOF and waiting for the other end to also send SSH_MSG_CHANNEL_EOF. RFC4254 explicitly allows sending SSH_MSG_CHANNEL_CLOSE without first sending SSH_MSG_CHANNEL_EOF, but maybe CoreFTP does not support that part of the RFC.

Please apply the patch that I just attached to this ticket and test if it solves the problem.

comment:3 follow-up: Changed 2 years ago by qxu

Great, Peter! Yes, the problem is fixed. There is no more visible delay. Thanks a lot for your quick fix!

PS: Your fix was sent out 3 days ago. I am sorry to verify it and reply you late, coz I took 2 days' leave last week.

comment:4 in reply to: ↑ 3 Changed 2 years ago by stuge

  • Resolution set to fixed
  • Status changed from accepted to closed

Replying to qxu:

Yes, the problem is fixed.

Great! Thank you for testing! This is commit 16af813b812aca09c73045288040ddf1a03a2b86

Note: See TracTickets for help on using tickets.