Client Upload Completes but Never Returns

Oct 1, 2014 at 10:01 AM
Edited Oct 2, 2014 at 7:05 AM
Hi, came across this library, looks like a life saver. Got it working pretty quickly and uploading files over SFTP (all I need to do at this time).

The following code is my simple implementation:
        public static string UploadSftp(string tempFilename, string host, string path, string username, string password)
        {
            using(SftpClient client = new SftpClient(host, username, password))
            using (FileStream stream = new FileStream(tempFilename, FileMode.Open, FileAccess.Read))
            {
                client.Connect();
                client.UploadFile(stream, path, Test);
                client.Disconnect();
            }

            File.Delete(tempFilename);

            return string.Empty;
        }
        public static void Test(ulong result)
        {
            Debug.WriteLine(result);
        }
This uploads the file file and I get the progress reported correctly via the test callback. However client.Disconnect() never gets hit. I know I am missing something dead simple here, something Async - can anyone spot my schoolboy error?

Edit: Looks like the problem is caused waiting for a response to the Disconnect message:
SshNet.Logging Verbose: 1 : SendMessage to server 'DisconnectMessage': 'SSH_MSG_DISCONNECT'.
I believe the disconnect is happening but there is no confirmation returned, the SftpClient then is in a waiting state. A few minutes later it seems to timeout and continue.