Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
edwinyzh opened this issue Jun 15, 2021 · 3 comments
Open

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

edwinyzh opened this issue Jun 15, 2021 · 3 comments

Comments

@edwinyzh
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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"'.

@pyscripter
Copy link
Owner

pyscripter commented Mar 16, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants