This project is read-only.

Client Upload Completes but Never Returns

Oct 1, 2014 at 11:01 AM
Edited Oct 2, 2014 at 8: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.UploadFile(stream, path, Test);


            return string.Empty;
        public static void Test(ulong 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.