Subject: SFTP transfer hangs when the server connection has high latency RTT around 500 ms and 30% packet loss

SFTP transfer hangs when the server connection has high latency RTT around 500 ms and 30% packet loss

From: Ketul Barot <kbarot_at_parallelwireless.com>
Date: Wed, 27 Feb 2019 16:02:42 +0000

Hello,

libssh2version: 1.7.0
Operating system: Linux (OpenWRT)

I am facing a hang when trying to upload a file using sftp protocol. The connection between my device and the server has high latency of 500ms and a packet drop rate of 30% which is manually introduced. I am using libcurl for doing the sftp transfer. In the code I have also implemented a libcurl progress function to provide a timeout so that when the timeout is reached I can abort the transfer if the upload is stuck. Most of the times this works fine and curl cleans everything perfectly.

After the abort callback I start the cleanup process as follows:
curl_multi_remove_handle
curl_easy_cleanup
curl_multi_cleanup (If this was the last easy handle)

With the same setup, occasionally the transfer gets hung at curl_multi_remove_handle. Up on examining this with the libcurl team (more on this can be found here<https://curl.haxx.se/mail/lib-2019-02/0065.html>). We found that the issue is with libssh2 as in when libssh2_session_disconnect is called by libcurl. It just returns error EAGAIN again and again and just gets stuck here.

To eliminate if libssh2 is the real reason for the hang. I used sftp_write_nonblock.c as an example from the libssh2 examples and used that to upload a file in my setup and here to I am seeing the same behavior that the sftp_write_nonblock application get's hung.

Would greatly appreciate if some one can look in to this. Also, I can provide any extra debug information that would help to resolve this issue.

Thanks,
Ketul

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2019-02-27