[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting timeout for ssh_connect() only


Hi Jakub,

Thanks for your reply.

IMHO the actual issue is that, without reading the complete library code, it's not clear where SSH_OPTIONS_TIMEOUT has it's influence. The documentation says only "Set a timeout for the connection in seconds".
So it would be convenient to set a connection timeout which really only affects the connecting, without having to care about the rest (internal polling etc.)...

Cheers
Till

July 2, 2025 9:22 PM, "Jakub Jelen" <jjelen@xxxxxxxxxx (mailto:jjelen@xxxxxxxxxx?to=%22Jakub%20Jelen%22%20<jjelen@xxxxxxxxxx>)> wrote:
On Tue, Jul 1, 2025 at 1:32 PM <g4-lisz@xxxxxxxxxxxx (mailto:g4-lisz@xxxxxxxxxxxx)> wrote:

Hi there

If I interpret the code right, there's a default timeout for ssh_connect() of 10 seconds as long as no user timeouts are set (and the session is blocking).

I think you are right.
IMHO the timeout for opening the connection should not be coupled to the general polling timeout...
It would be a nice feature to have an option for ssh_connect() only, e.g SSH_OPTIONS_CONNECT_TIMEOUT. Or through a second parameter: ssh_connect(session, timeout).

Is the initial connection timeout that much different from other internal poll timeouts? Technically, it might make a bit more time to bubble the initial packets through NATs and stuff, but if you use poll later in your application, you can specify your timeout already.
Will this work as intended?

int conn_timeout = 5; // custom connect timeout
ssh_options_set(session, SSH_OPTIONS_TIMEOUT, conn_timeout);
ret = ssh_connect(session);
/* handle ret */
ssh_options_set(session, SSH_OPTIONS_TIMEOUT, 0);

Does SSH_OPTIONS_TIMEOUT 0 set the default behavior?

Yes, calling this will set the internal value to 0 and this is interpretted as default, 10s timeout so your suggestion should work.

Jakub

References:
Re: Setting timeout for ssh_connect() onlyJakub Jelen <jjelen@xxxxxxxxxx>
Setting timeout for ssh_connect() onlyg4-lisz@xxxxxxxxxxxx
Archive administrator: postmaster@lists.cynapses.org