0 votes
by (120 points)
edited

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
by (147k points)
edited

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!

by (147k 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.
...