Timeouts and possible SFTP design issues - WeOnlyDo Discussion board

Timeouts and possible SFTP design issues (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Cameron, Monday, December 01, 2014, 20:01 (1328 days ago)


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 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);
            Console.WriteLine("before putfile");


                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");

Complete thread: