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

Timeout in channel_open_session


Please, I need your advice about channel_open_session function.

I have a timeout configuration parameter in my application.

First of all, I create an instance of my custom connection class and set ssh
options according to my configuration using this piece of code (class

if (ssh_options_set(session_id, SSH_OPTIONS_TIMEOUT, &timeout_s) != 0) {



int ret = ssh_connect(session_id);

if (ret == SSH_ERROR) {




This code works fine and connection timeout is handled correctly in this

Also I have the following code, which creates ssh channel for remote shell
commands execution, it’s called from methods of the custom connection class
mentioned above:

SSHChannel(ssh_session pSSH): p_channel(NULL) {

p_channel = channel_new(pSSH);

      if (p_channel == NULL) throw SSHError("SSHChannel unable to allocate
new channel for session ", to_str(pSSH), " Error message ",

if (channel_open_session(p_channel) != SSH_OK) {


p_channel = NULL;



So, the problem is in the following:

if I’ve established ssh connection successfully using ssh_connect method,
and then after some time link between ssh client and server is broken (due
to some communication problems or firewall enabled), the call of
channel_open_session method from the second code snippet hangs the
application up to 15 minutes, while timeout being set in ssh_options_set was
about 30 seconds.

The question is – how can I specify a reasonable timeout for
channel_open_session calls or how else can I work this situation around?

Thanks in advance.



 Valentin Rodygin.

Re: Timeout in channel_open_sessionAndreas Schneider <asn@xxxxxxxxxxxx>
Re: Timeout in channel_open_sessionAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org