psantann has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I'm having the following issue with Net::SSH2 on a Fedora 2.6.27.5-117.fc10.i686 box. Note that same code works well on Ubuntu, FreeBSD and CentOS.

I'm able to open a connection and a channel to a device, but when I try to read from a channel, code gets blocked in the following line:

while ( my $line = <$handle> ) {

Where $handle is a Net::SSH2::Channel object. I can read the contents of the channel only if I do the following instead:

my $line;
$handle->read( $line, 657 );

657 is the exact number of bytes available on the channel at that time, if I try to read more, or read in a loop, I get stuck again. Only reading the exact 657 bytes works.

libssh2 is version 1.2.7 and Net::SSH2 version is 0.33. Same version I have working on Ubuntu and FreeBSD.

Any ideas?

Thanks, Paulo
  • Comment on Net::SSH2 blocked while reading from Channel

Replies are listed 'Best First'.
Re: Net::SSH2 blocked while reading from Channel
by salva (Canon) on Mar 19, 2011 at 07:15 UTC
      Hi Salva, No users with windows yet. Bracing myself for that :-)

      I like how Net::SSH2 works with channels and subsystems, a cursory look at Net::OpenSSH does not reveal much on that but I will take a closer look.

      Still is very odd that many Unix flavors work just fine and just Fedora has an issue... it gets me wondering what could possibly be the cause of that? Does not seem to be an issue with Net::SSH2 itself.

      Thanks,

      Paulo
        I like how Net::SSH2 works with channels and subsystems, a cursory look at Net::OpenSSH does not reveal much on that but I will take a closer look.

        Net::OpenSSH does not expose the Channel concept to the user. It gets hidden behind higher level and more familiar abstractions (i.e. processes, pipes, redirections, etc.).

        Still is very odd that many Unix flavors work just fine and just Fedora has an issue...

        Net::SSH2 and the libssh2 library are not mature yet and critical bugs still pop up now and there... though, they are active projects so try to write a minimal script reproducing the error and send it to the module author.

        Hi Paulo, Did you get any resolution for this? I have the same issue on my suse linux, but it doesn't work with the exact bytes too for me. How did you get the exact number of bytes in the channel? Could you please paste your code? Thanks, Madhuri