Timeouts and possible SFTP design issues (wodSFTP / wodSFTP.NET / wodSFTPdll)
Hi,
I work for a company which uses the WOD .NET SFTP libraries.
We are running into an issue of WeOnlyDo.Exceptions.SFTP.TimeoutException exceptions
being thrown consistently in situations where they should not be throw.
[We see the Exception thrown as a result of a receive timeout, where we can verify via Wireshark
that SFTP packets over SSH are being received.]
I believe there may be an issue with the libraries where the receiver timeouts occur because
of buffer management issues relating to insufficient memory, or buffer GC pinning causing
EndReceive() calls not to occur for durations greater than the SFTP.Timeout setting.
More info on the pinning of buffers for async socket usage: http://goo.gl/xR2wiB
This program below causes the issue consistently for us.
The program below throws the exception consistently about 30 seconds after transfer start, yet packets are being received and transmitted on the SFTP socket. [As confirmed by Wireshark]
We test against an approximately 500KB/sec channel.
We are testing against the 3.4.7.121 version of the DLL.
Any feedback is appreciated.
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using WeOnlyDo.Client;
namespace WOD2
{
class Program
{
static void Main(string[] args)
{
Random rng = new Random(); // random number generator
var b = new byte[(int)500e6]; // create 500MB byte array
rng.NextBytes(b); // fill array with random bytes
var str = new MemoryStream(b); // create memorystream of bytes
var stopwatch = new Stopwatch(); // timer for measuring
Assembly assembly = Assembly.GetAssembly(typeof(SFTP));
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fvi.FileVersion;
Console.WriteLine("WOD SFTP DLL version {0}", version);
SFTP sftp = new WeOnlyDo.Client.SFTP();
sftp.Hostname = "host";
sftp.Login = "login";
sftp.Password = "pass";
//sftp.Timeout = 0;
sftp.Blocking = true; //Use synchronous connections
Console.WriteLine("before connect, timeout = {0}", sftp.Timeout);
sftp.Connect();
Console.WriteLine("before putfile");
stopwatch.Start();
try
{
sftp.PutFile(str, "bigfile." + rng.Next() + ".bin");
}
catch (WeOnlyDo.Exceptions.SFTP.TimeoutException)
{
Console.WriteLine("TimeoutException after {0:f} seconds", stopwatch.Elapsed.TotalSeconds);
}
Console.WriteLine("completed {0:f} seconds after start", stopwatch.Elapsed.TotalSeconds);
if (Debugger.IsAttached)
{
Console.WriteLine("waiting for key");
Console.ReadKey();
}
}
}
}
Timeouts and possible SFTP design issues
Hi Cameron.
I am trying to duplicate your issue, but it works for me. Do you know what type/version of SSH server you're connecting to? I'd like to try with same to see if I can get the same problem.
It works for me on local LAN with latest OpenSSH in my tests.
Jasmine.
Timeouts and possible SFTP design issues
Please try the program with the Cerebrus SFTP server.
http://www.cerberusftp.com/
Thanks,
Cameron
Timeouts and possible SFTP design issues
Cameron,
hi. Seems that Cerberus server does not reply fast enough with status packets matching our write packets, so we don't receive confirmation about packets being received successfully by the server. Since we're sending them at high speed, it probably waits for confirmation, but doesn't have a chance to eventually send them.
Anyway, we've made workaround for Cerberus so we slow down sending packets. Now it all works ok. Please request update and try it out, wodSFTP.NET version 3.4.7.123
Regards,
Kreso