Upload problem

Feb 21, 2012 at 1:02 PM


I'm working on a console app that watches a folder and, if a new file is created/copied, zip that file and upload it to an SFTP server.

SFTP server is running WinSSHD (http://www.bitvise.com/winsshd)

When I try to upload a file (size about 300Kb) I get the following exception:

2012-02-21 14:52:25,183 ERROR - System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)   at Renci.SshNet.Session.SocketWrite(Byte[] data)   at Renci.SshNet.Session.SendMessage(Message message)   at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request)   at Renci.SshNet.Sftp.SftpSession.RequestWrite(Byte[] handle, UInt64 offset, Byte[] data, EventWaitHandle wait)   at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, SftpUploadAsyncResult asynchResult, Flags flags)

In WinSSHD log I read the following error:

The client has been disconnected, we sent the following disconnect reason:  SSH_DISCONNECT_PROTOCOL_ERROR, description: data exceeds negative window  tolerance

My code:


  sftpClient.UploadFile(File.OpenRead(tempFolder + zipName), destinationFolder + zipName);
catch (Exception ex)
 log.Error(" Unable to upload file to SFTP folder " + destinationFolder);
 return 2;

Variable values are:

tempFolder = D:\Temp\

zipName = FAX-20120221_145222.zip

destinationFolder = /Faxes/

File D:\Temp\FAX-20120221_145222.zip exists and if I upload it manually (win WinSCP) everything works fine.



Feb 21, 2012 at 1:42 PM



I just an upload test of few 600MB files and it worked fine for me.

If you like, I can logon into your server using test account so I could see the error occurs and possible to fix it.

I used this code to do the test:

using (var sftp = new SftpClient(connectionInfo))
                for (int i = 0; i < 10; i++)
                    sftp.UploadFile(File.OpenRead(@"D:\source.mpg"), "test.mpg");

Hope it helps,