Subject: "Unable to request a channel from remote host"

"Unable to request a channel from remote host"

From: Ian Schorr <ian.schorr_at_gmail.com>
Date: Tue, 16 Jun 2009 10:44:33 +1000

Hello all,

I recently moved some PHP code from one server to another that uses libssh2
and the pecl ssh2 library. I'm getting some weird errors now, and wondering
if anyone has any ideas.

Sorry if this is the wrong list for this - I honestly don't know if this is
a libssh2 problem or a pecl ssh2 issue, and their website implies that the
libssh2 homepage is theirs as well...

Anyway, I have some code that does:

302: $stream=ssh2_exec($this->sshConnection, $execstring);
304: stream_set_blocking( $stream,false );
316: $line = fgets($stream);
322: fclose($stream);

...And then loops for several $execstrings. It's actually a bit more
complicated than this, I have some logic to determine when the output's
complete and to stop trying to read lines. The minimum time between open
and close is 250ms, though.

After the first time I do this, I start getting the errors:

*Warning*: ssh2_exec(): Unable to request a channel from remote host
in*utils.php
* on line *302*
*Warning*: stream_set_blocking(): supplied argument is not a valid stream
resource in *utils.php* on line *304*
*Warning*: fgets(): supplied argument is not a valid stream resource in *
utils.php* on line *316

*...It looks like the ssh connection has some problem after I close the
ssh2_exec stream.

This works fine with my old server, which has libssh2 0.13 and the pecl ssh2
0.10. New one has pecl ssh2 0.11 and I've tried libssh2 0.18, 1.0, and now
1.0.1, but with the same problem on each. I've had some problems getting
the older libraries installed on the newer system - I may take a crack at it
next and see if I can narrow down what changes are related to the problem.

Curiously the problem goes away if I set "blocking" to true. The problem
there is that it's much more difficult for me to detect and handle
situations where remote commands "hang", which is a possibility.

Has anyone seen this before? Any ideas on what might be going wrong or
debugging that could be done? Is there a more "gentle" way to tear down the
streams here?

Thanks,
Ian

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects

_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-06-16