Jump to content

Is it possible to wear out an ssh2 connection?


AFTNHombre

Recommended Posts

I have this problem where I make an ssh2 connection in this class, use it several times, and then it breaks, as in, further calls that use that resource fail. What happens is I make several ssh2_scp_recv() calls, then I call:

$stream = ssh2_exec(EX_SFTP::$connection, "date --utc -r conf/au.conf  '+%Y-%m-%d %H:%M:%S'; echo __COMMAND_FINISHED__");

That succeeds, then $stream is read, and the command is determined to be finished when "__COMMAND_FINISHED__" is parsed. (The only thing done w/$stream is that it is passed to fread() and strlen(). It isn't closed, or anything)

Now the next thing I do is call ssh2_scp_send(), which results in an exception whose message is "ssh2_scp_send(): Failure creating remote file". The reason I think the connection somehow wore out is that a boorish solution I tried was to reconnect to the server every time I use EX_SFTP::$connection. So only using fresh connections is an answer, but I can do better than that. Unfortunately, I don't know of any reliable way to test the health of a connection.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.