Renci.SshNet.Common.SshOperationTimeoutException

Aug 15, 2013 at 12:22 AM
Edited Aug 15, 2013 at 12:52 AM
Hi - I'm getting the error when I attempt to upload a file to our vendor's server. I can upload just fine to our dev server (same code and file). Also, I'm able to connect/upload to the vendor server using File Zilla (sftp).

Any ideas on what's going on? I can provide the vendor site & credentials (privately) if you want to try it. The system.diagnostics trace file is 100+ lines; I can email it or post here if needed.

Thanks for your help!

Code
           using (var sftp = new SftpClient(host, username, password))
            {
                sftp.Connect();
                //sftp.SendKeepAlive(); didn't make a difference

                using (var file = File.OpenRead(@"file.txt"))
                {
                    sftp.UploadFile(file, remoteFileName);
                }

                sftp.Disconnect();
            }
Exxception:
Renci.SshNet.Common.SshOperationTimeoutException was unhandled
HResult=-2146233088
Message=Session operation has timed out
Source=Renci.SshNet
StackTrace:
   at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle)
   at Renci.SshNet.Channels.Channel.WaitHandle(WaitHandle waitHandle)
   at Renci.SshNet.Channels.Channel.SendMessage(ChannelDataMessage message)
   at Renci.SshNet.Channels.Channel.SendData(Byte[] buffer)
   at Renci.SshNet.Sftp.SubsystemSession.SendData(Byte[] data)
   at Renci.SshNet.Sftp.SftpSession.SendMessage(SftpMessage sftpMessage)
   at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request)
   at Renci.SshNet.Sftp.SftpSession.RequestWrite(Byte[] handle, UInt64 offset, Byte[] data, EventWaitHandle wait, Action`1 writeCompleted)
   at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, Flags flags, SftpUploadAsyncResult asyncResult, Action`1 uploadCallback)
   at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Boolean canOverride, Action`1 uploadCallback)
Nov 20, 2013 at 3:46 PM
Any resolution to this? I am running into the exact same issue with code that looks almost identical. Any insight you have would be appreciated. Thanks!
Nov 25, 2013 at 1:40 PM
Ended up using edtFTPnet/PRO.
Feb 12, 2015 at 4:29 PM
I'm getting the same error when calling SftpClient.UploadFile() to upload a large-ish file (~600Mb) to a FreeBSD UNIX file server, it fails after transferring half the file (several minutes later).
I'm using SSH.NET 2014.4.6-beta2.
Maybe I should be using the asynchronous upload, sftp.BeginUploadFile(). Any thoughts/suggestions?
Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out 
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout) 
at Renci.SshNet.Session.Renci.SshNet.ISession.WaitOnHandle(WaitHandle waitHandle) 
at Renci.SshNet.Channels.Channel.WaitOnHandle(WaitHandle waitHandle) at Renci.SshNet.Channels.Channel.GetDataLengthThatCanBeSentInMessage(Int32 messageLength) 
at Renci.SshNet.Channels.Channel.SendMessage(ChannelDataMessage message) 
at Renci.SshNet.Channels.Channel.SendData(Byte[] data) 
at Renci.SshNet.SubsystemSession.SendData(Byte[] data) 
at Renci.SshNet.Sftp.SftpSession.SendMessage(SftpMessage sftpMessage) 
at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request) 
at Renci.SshNet.Sftp.SftpSession.RequestWrite(Byte[] handle, UInt64 offset, Byte[] data, AutoResetEvent wait, Action`1 writeCompleted) 
at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, Flags flags, SftpUploadAsyncResult asyncResult, Action`1 uploadCallback) 
at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Boolean canOverride, Action`1 uploadCallback) 
at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Action`1 uploadCallback) 
at Centauri.Management.UnixInterfaceManager.Transfer(String sourceFilePath, String destinationFilePath) in C:\XXXX\UnixInterfaceManager.cs:line 183 
Sep 8, 2015 at 3:41 PM
We were experiencing this exact problem; updating to the newest version of SSH.NET fixed it. Version 2013.4.7 exhibits this problem. Version 2014.4.6-beta2 does not.