[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Setting timeout for ssh_connect() only
[Thread Prev] | [Thread Next]
- Subject: Re: Setting timeout for ssh_connect() only
- From: Jakub Jelen <jjelen@xxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 2 Jul 2025 21:22:55 +0200
- To: libssh@xxxxxxxxxx
On Tue, Jul 1, 2025 at 1:32 PM <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
Setting timeout for ssh_connect() only | g4-lisz@xxxxxxxxxxxx |