Ssh-Pascal icon indicating copy to clipboard operation
Ssh-Pascal copied to clipboard

The "timeout" doesn't seem to be working...

Open edwinyzh opened this issue 4 years ago • 3 comments

So with PR #6 I added the libssh2_session_set_timeout API.

However, although with this PR, SetTimeout(gDefaultSshTimeout) is called in TSshSession.Connect, where gDefaultSshTimeout is set to 30 seconds by default.

But according to my tests, after 30 seconds of a command execution of no return, the expected LIBSSH2_ERROR_TIMEOUT error (Docs here) are not raised, not sure why...

edwinyzh avatar Jun 15 '21 09:06 edwinyzh

For supplying more details, just now I was quitting the program and the debugger stopped at the following line in ReadStringFromChannel():

BytesRead := libssh2_channel_read_ex(Channel, StreamId, Buf, BufLen);

ssh-pascal hang

edwinyzh avatar Jun 15 '21 10:06 edwinyzh

More details Part 2: Although the timeout error doesn't seem to work with libssh2_channel_read_ex as described in the above reply, libssh2_channel_open_session does produce the timeout error, because I just encountered the following exception:

Project Program1.exe raised exception class ESshError with message 'LibSSh2 error: Timed out waiting on socket (-9), on API "libssh2_channel_open_session"'.

edwinyzh avatar Jun 15 '21 10:06 edwinyzh

Sorry for the long delay in getting back to you.

Is the channel blocking or not? (see https://libssh2.org/libssh2_session_set_blocking.html)

If it is not libssh2_channel_read_ex is non-blocking and does not timeout. It returns immediately with LIBSSH2_ERROR_EAGAIN if there is no data available. You can implement a timeout using the Cancelled variable. (see https://libssh2.org/libssh2_channel_read_ex.html)

pyscripter avatar Mar 16 '24 22:03 pyscripter