in reply to Re^2: Net::ssh2 timeout
in thread Net::ssh2 timeout

Is there a way to increase the amount of time it waits for a response?

The only reference I can find to "timeout" in the Net::SSH2 documentation is in relation to the poll method. Looking at the test script that's part of the source distro, it seems that $ssh2->poll(0); sets the timeout to indefinite.

Now, I have no idea what 'poll' actually does, but since it's apparently the only way to set a "timeout", I guess you could try setting it and see what happens. (Good luck :-)

Other than that, I'd be starting to wonder if there's a problem at the other end with the SSH2 server that they're running.

Cheers,
Rob

Replies are listed 'Best First'.
Re^4: Net::ssh2 timeout
by llass61 (Novice) on Nov 07, 2007 at 16:51 UTC
    Thanks for all the help. The "poll" did not work. The frustrating th +ing is that I can get certain things to work (the connection is there +, but the stuff I want to work times out). All I'm trying to do is g +et/put a file on a server. You may be right that it has something to + do with their server (but why would the sftp work described below?). + Anyway, this is what I have. You will notice that the last call (s +ftp) works ok, but the first two (get, channel) do not. ******** CODE **************** use Net::SSH2; use Net::SSH2::Channel; use IO::Scalar; use strict; my $handle = IO::Scalar->new;; my $ssh2 = &connect('ftp.xxxx.com','XXX','PASSWORD'); sub connect { my $host = $_[0]; my $user = $_[1]; my $pw = $_[2]; my $ssh2 = Net::SSH2->new(); $ssh2->connect($host); if ($ssh2->auth_password($user, $pw)) { print "\nIN SFTP\n"; $ssh2->poll(0); $ssh2->scp_get('./test/out/aFile.txt', $handle); print "Error: ", $ssh2->error(), "\n"; $handle->seek(0, 0); _read($handle); print "Reading channel\n"; my $chan = $ssh2->channel; $chan->exec('cat ./test/out/aFile.txt') or die "NO Way +\n"; print "Error: ", $chan->error(), "\n"; _read($chan); print "Reading channel\n"; # (b) read a line at a time with SFTP my $sftp = $ssh2->sftp; my $file = $sftp->open('./test/out/aFile.txt') or die +"No Way Again\n"; print "Error: ", $sftp->error(), "\n"; _read($file); } $ssh2->disconnect(); return $ssh2; } sub _read { my $handle = shift; while (my $line = <$handle>) { print "Getting a line\n"; print $line; } } ****************** RESULTS ***************** IN SFTP Error: -28LIBSSH2_ERROR_SCP_PROTOCOLTimed out waiting for SCP response Reading channel Error: -28LIBSSH2_ERROR_SCP_PROTOCOLTimed out waiting for SCP response Reading channel Error: 0SSH_FX_OK Getting a line aaaaaaaaaaaaaaaaaaaaaaaaa (THIS IS THE CORRECT DATA IN THE FILE) THANKS