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

sftp_write waits infinitely


Hello,


I am having a problem with sftp transfer. I have the following test setup:

  1.  A machine which accepts ssh connections.
  2.  My machine which sets up connection to the first machine and transmits a large file.

During the transmission of the file I unplug the network cable of machine 1. Program on my machine waits somewhere in sftp_write.

After 20 minutes or so I plug the network cable.  Program still waits in sftp_write and will do this forever!

I debugged into this problem and noticed that ssh_channel_read_timeout is called with timeout = -1, which means infinite timeout.

I am using the default blocking ssh_session and sftp_file.

I am also using this:
int timeout = 10;
ssh_options_set(sshSession, SSH_OPTIONS_TIMEOUT, &timeout);
Setting the sftp file to nonblocking changes nothing as the nonblocking flag is only used for sftp file read.

When using ssh_set_blocking(sshSession, 0) even connecting the ssh session won't work!

So how do I implement a SFTP file transfer, which runs into a timeout of 10 seconds if connection is lost and then returns?



Best regards

Jakob Kohl
Software Entwicklung

[nowcast GmbH]


nowcast GmbH
Albert-Roßhaupter-Str. 43
81369 München

Phone: +49.(0)89.5529.713.85
Fax: +49.(0)89.5529.713.71

jakob.kohl@xxxxxxxxxx<mailto:jakob.kohl@xxxxxxxxxx>
www.nowcast.de<http://www.nowcast.de>

Geschäftsführung / Management Board: Alexander Betz, Irmtraud Königshofer
Sitz der Gesellschaft / Registered Office: München
Registergericht / Court of Registration: AG München, HRB 147454
USt.-Id: DE 233256369

Follow-Ups:
AW: sftp_write waits infinitelyJakob Kohl | nowcast GmbH <jkohl@xxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org