SSH/SFTP servers are notoriously bad at providing any sort of useful information about the cause of a problem. This is one of those cases. It was discovered that for one particular server, if a remote file is opened (via the OpenFile method) using “readWrite” access, then the OpenFile succeeds, but a subsequent call to a method such as ReadFileBytes fails. The only information from the server is an error code “10”. Gee, thanks! What the #@!$%! is an error code “10”??? (Usually an SSH server will also provide a short and utterly useless 1-line error description, but this particular server was too lazy to even do that.)
In the end, after fiddling around with different access and disposition choices, it was found that using “readOnly” for the access and “openExisting” for the create disposition solved the problem.
If the SSH/SFTP server responds with a “Folder not found” error in response to calling OpenFile with a remote filepath is just a filename with no path part, then try prepending “./” to the filepath. For example:
success = sftp.OpenFile(“test.txt”, “writeOnly”, “createTruncate”);
If this fails with a “Folder not found”, then modify your code to this:
success = sftp.OpenFile(“./test.txt”, “writeOnly”, “createTruncate”);
(With permission from a Chilkat customer, for the benefit of others..)
We did some extensive testing and found that our client sees this on their end what the connection fails:
SERVER: 13.07.2010 15:21:43 (57220) session ended on error, Buffer missing (error 132).
Do you know what that could possibly mean in relation to Chilkat’s SFTP?
“The issue ended up being a security appliance (Untangle) we had. We added a bypass rule in there for port 22 and it went from working 3/5 times to 5/5 times.”
I receive strange characters when downloading a text file using ReadFileText. Why does this happen?
Using SSH/SFTP, files are downloaded exactly as-is byte-for-byte except if you call the ReadFileText* methods. The ReadFileText* methods require a charset (i.e. character encoding) to be specified in the method arguments. This allows the method to interpret the bytes according to a specific character encoding (such as utf-8, windows-1252, Shift_JIS, etc.) and then return the correct string (because strings in programming environments using ActiveX, or languages such as C#, VB.NET, Java, etc are objects with an internal Unicode representation).
I’ve downloaded the trial version of your FTP2 ActiveX control. I’m
using it in Visual FoxPro 9, but need to have a progress bar to track
an upload. When using your asynchronous example code, the progress
bar jumps from 0 to 524288 and so on. I need much more precision than
that so the progress bar will update smoothly. How do I accomplish
this with your tools?
Set the SendBufferSize property to a smaller value, such as 8192. The FTP2 component has the SendBufferSize property. The equivalent property in SSH/SFTP is MaxPacketSize.
I’m just beginning to work with some of the Chilkat components and I’ve
run into an apparent issue with the ReadFileBytes method in the
I’m attempting to read an entire file using ReadFileBytes and only
getting part of the file. Here’s essentially what I’m doing:
* Use GetFileSize32 to get the size of the file (returns 168914)
* Use ReadFileBytes passing in that length (168914) as the number
The result is that I get 50000 bytes.
Is there a 50000 byte limit in ReadFileBytes?
The 2nd argument to ReadFileBytes is the maximum number of bytes you want to read.
The method may return with a lesser number of bytes. To read the entire file, you would call ReadFileBytes repeatedly until you reach the EOF.
(See the reference documentation at http://www.chilkatsoft.com/refdoc –> “To read an entire file, one may call ReadFileBytes repeatedly until Eof(handle) returns true.” )