Is there a solution for Sftp.Timeout functionality when using the GetUploadStream to upload?

0 votes
asked Dec 10, 2010 by Al Marshall (120 points)
edited Mar 21, 2011

Is this a bug? Is there an alternate solution?

I'm uploading to an SFTP server via writes to the stream provided by Sftp.GetUploadStream and I want to provide an upper limit on the amount of time a transfer is allowed to take. Sftp.Timeout is not working for me.

When I simulate a hung server by suspending the SFTP server in the middle of a Rebex client's very large Write to this Stream, the upload simply hangs for an arbitrary period of time, despite the fact that I have Sftp.Timeout set to 1000 on the client.

This behavior can also be produced with Sftp.PutFile(stream, filename).

In general, it appears that Sftp.Timeout is effective if the server process is suspended just prior to the PutFile or stream Write. If however it is suspended in the middle of a large PutFile or Write, the client hangs.

Rebex.Net.Sftp.dll v 2.0.3854.0

1 Answer

0 votes
answered Dec 12, 2010 by Lukas Pokorny (99,010 points)
edited Dec 13, 2010

First, let me clarify Sftp object's Timeout property's behavior:

  • Timeout is not an upper limit on the amount of time a transfer is allowed to take.
  • Timeout is an upper limit on the amount of time an Sftp object method is going to spend waiting for a server response for each SFTP packet (which includes data packets sent by PutFile or uploadstream's Write methods).

If you suspend the SFTP server in the middle of a very large Write, it should time out quickly because even very large writes only send data in 64KB packets internally.

This means that the behavior you describe is indeed not the desired one. We will look into this issue tomorrow and try to reproduce it!

Update: It looks like the uploadstream's Write method or Sftp's PutFile method might not time out properly if the transfer gets stuck at TCP send level. We will try to fix this now and send you a link to a new version of Rebex SFTP when it's ready. Thanks for reporting this issue!

commented Dec 14, 2010 by Lukas Pokorny (99,010 points)
I just sent a link to the current build of Rebex SFTP that should fix this issue to your e-mail address. Please give it a try and let us know whether it helps.
...