curl-library
sftp upload request hangs with a slow connection server using multi interface
Date: Fri, 25 Jan 2019 15:16:10 +0000
Hello,
Libcurl version: 7.61.1
curl 7.61.1 (arm-none-linux-gnueabi) libcurl/7.61.1 GnuTLS/3.5.13 zlib/1.2.8 libssh2/1.7.0
Release-Date: 2018-09-05
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS Debug TrackMemory IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets HTTPS-proxy
Operating system: Linux (OpenWRT)
I am facing a hang followed by SIGABRT 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 60% which is manually introduced. I am using curl_multi interface as I have lot of files to upload periodically and in an unblocking fashion. In the code I have also implemented a 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 which I do by returning non-zero value from the progress callback I follow this sequence:
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. Upon enabling the CURLOPT_VERBOSE option I found that the curl get hung at "SFTP 0x1c739e8 state change from SSH_SFTP_SHUTDOWN to SSH_SESSION_DISCONNECT". When compared with a proper cleanup it does more things after this SSH_SESSION_DISCONNECT state that is:
SFTP 0x1c739e8 state change from SSH_SFTP_SHUTDOWN to SSH_SESSION_DISCONNECT
SFTP 0x1c739e8 state change from SSH_SESSION_DISCONNECT to SSH_SESSION_FREE
Marked for [closure]: SSH session free
SFTP 0x1c739e8 state change from SSH_SESSION_FREE to SSH_STOP
SSH DISCONNECT is done
Closing connection 0
The cache now contains 0 members
On further looking at the libcurl code I found this comment for the sftp_disconnect function in curl/lib/ssh.c file:
/* BLOCKING, but the function is using the state machine so the only reason
this is still blocking is that the multi interface code has no support for
disconnecting operations that takes a while */
static CURLcode sftp_disconnect(struct connectdata *conn, bool dead_connection)
I believe this issue is specifically because I have high latency between my device and the server it is trying to upload the file. If this really is the issue can you please look for a fix? If not then would appreciate your help to resolve it?
Thanks,
Ketul
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-01-25