in reply to Net::SSH2 connection timeout

Do I need to use poll() on the channel

From the documentation, it looks like that is what you need to do. I would try putting the poll in a separate thread, and passing in the ssh2 filehandle's fileno.

The docs say:

poll ( timeout, arrayref of hashes )
Pass in a timeout in milliseconds and an arrayref of hashes with the following keys:

handle
May be a Net::SSH2::Channel or Net::SSH2::Listener object, integer file descriptor, or perl file handle.

events
Requested events. Combination of LIBSSH2_POLLFD_* constants (with the POLL prefix stripped if present), or an arrayref of the names ('in', 'hup' etc.).

On linux, if the 'in' event fires, and there is no data to be read, then it can be interpreted that the connection is lost. See Net::SSH2 odd polling behavior for example. Also see Net::SSH2 Interactive command example for a similar problem.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Net::SSH2 connection timeout
by sparvu (Initiate) on Sep 12, 2012 at 17:53 UTC

    Cant use threads since my perl is built without thread support. Interesting about 'in', 'hup' . I need to try to test this part and read further.

    I sent some feedback to the author of Net::SSH2 that we could improve a bit the documentation and have more samples. That would be sweet.

    Very much appreciated your feedback. Later if Im successful the code will be available so anyone can reuse, change or take a look.