Net-SFTP - put() command hanging on files larger than 2kb or so - changing COPY_SIZE fixes

Posted on Fri Mar 31 23:17:00 2006 by mp
put() command hanging on files larger than 2kb or so - changing COPY_SIZE fixes
We're running version 0.10 of Net::SFTP and version 1.29 of Net::SSH::Perl. The server we're connecting to is a "5.0.1.79 SSH Tectia Server", with protocol version 2.0.

When small files are transferred Net::SFTP works perfectly. When they get larger than a few kilobytes they hang at this point:

sftp: Sending SSH2_FXP_INIT
sftp: Remote version: 3
sftp: Sent SSH2_FXP_OPEN I:0 P: "filename"
sftp: Sent message T:17 I:1
sftp: Received stat reply T:105 I:1
sftp: Sent message SSH2_FXP_WRITE I:2 O:0

That's in the "do_write" procedure. So we've been trying different things to figure out what's wrong, and one thing that worked is to change the value of COPY_SIZE in SFTP.pm from 8192 to something lower (4063 and lower seem to make it work).

Does anyone have an idea why this is happening and why changing COPY_SIZE fixed it? Below is the test script we're using:



use strict; use warnings; use Net::SFTP; my %args = (ssh_args => []); $args{debug} = 1; $args{user} = <user>; push @{ $args{ssh_args} }, identity_files => [ <identity_filename> ]; push @{ $args{ssh_args} }, options => [ "BatchMode yes", "Port 22" ]; push @{ $args{ssh_args} }, options => [ "PreferredAuthentications publickey", "HostKeyAlgorithms ss +h-dss,ssh-rsa", "BatchMode yes", "Port 22" ]; my $rhost = <rhost>; my $source_file = <source_file>; my $dest_file = <dest_file>; eval { my $sftp = new Net::SFTP($rhost, %args); $sftp->put($source_file, $dest_file); }; if ($@) { print "doh: $@\n"; }
Direct Responses: 2326 | Write a response