On Tue, 4 May 2010, Xu, Qiang (FXSGSC) wrote:
The test with the libssh2 example utility sftp_write_nonblock (./sftp_write_nonblock 13.121.8.133 <user> <pass> testSmall.pdf /Home/Scans/testSmall.pdf) succeeds, while curl command ( ./curl -v -k -u <user>:<pass> -T testSmall.pdf sftp://13.121.8.133/Home/Scans/) fails.
Yes, we've been back and forth a good while now with this knowledge. The problem seems to be related to how libcurl uses libssh2.
I am having difficulty in tracing sftp function flow in libcurl. For example, libssh2_sftp_write() is called in Curl_sftp_send(), which is called by Curl_write() in "sendf.c", and by readwrite_upload() in "transfer.c". For me, it is not as clear as in "sftp_write_nonblock.c".
Of course it isn't as easy to follow as libcurl is a multi-protocol library with a lot more features and functionality.
Since you are the developer and more familiar with the code, could you tell me what is the major difference between libcurl sftp code and the code in "sftp_write_nonblock.c"?
Believe me, if I had a good idea where this bug is I would tell you. Some things that may differ are packet/buffer sizes. I'm a bit puzzled that the SFTP server you communicate with returns a "packet too long" error message. Is there any chance that you can see some server logs to see what kind of packet it means and how long too long might be? I'm quite positive libssh2 stays within the set boundaries of what SSH and SFTP allow, but maybe the server is particularly picky in some regard. A somewhat crude way to try a smaller buffer with libcurl is to change the CURL_MAX_WRITE_SIZE define in curl/curl.h and rebuild the library and see if that makes anything different.
Other than this, I can only advice that you start regular debugging. Instrument the code like you started, figure out when it goes wrong and dig in and try to figure out exactly *why* it goes wrong when it does. Yes it may involve both libraries. Yes it may involving reading up on SSH and SFTP protocol details. No it isn't exactly easy.
Another way is of course to up the efforts to allow others to see the problem and thus help out from our ends.
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
