Why is Net::SSH2::File only allowing 32500 bytes on a write?
I have a Redhat 5.5 Linux machine using Perl Net::SSH2 to sftp a file. It appears that once the filehandle is opened for writing, I can only write a maximum buffer length of 32500 bytes for each call to $fh->write($buffer). I've had to limit my file read to 30*1024 bytes before 开发者_运维百科writing it to the Net::SSH2::File filehandle. Shouldn't I be able to write a larger buffer? The filesize I am copying is about 800k. The buffer I am talking about is the size of the write chunk. I can continually write this chunk size.
It's apparently a hard-coded limit in Net::SSH2. See here:
http://www.libssh2.org/mail/libssh2-devel-archive-2010-06/0104.shtml
Most SSH servers limit the size of the packets they can handle to some size around 32Kb and so clients do the same for interoperability.
You can use Net::SFTP::Foreign, that doesn't have that limitation (its buffers will grow to accommodate data of any length as far as memory is available) and it can run on top of Net::SSH2 via the Net_SSH2 backend Net::SFTP::Foreign::Backend::Net_SSH2 or just use the OpenSSH binary client.
精彩评论