This project is read-only.

Error: Connection was lost

Mar 26, 2012 at 7:31 AM

Hi Oleg,

I have a problem similar to the one described here:

When I try to upload a file to my sftp server and to my client's sftp server I was getting error "Payload cannot be more then 32768". So I did as suggested in the post and reduced buffer size to 1024 * 28. Now the error I get is "Connection was lost". It creates an empty file on the server but fails to write whole data (in fact the total size remains 0 byte.). It crashed while I was trying to upload a file of 27 KBs. I am using 7 December release.

Any ideas?

Apr 11, 2012 at 12:17 PM
Edited Apr 11, 2012 at 12:17 PM

Hi again,


I am reviving this post as it continues and I see other people having the same issue. As a change I tried the latest release (9 March), not working again. We watched the connection with wireshark and we saw packets are transfering and connection is closed normally on our side.

Apr 13, 2012 at 2:02 PM




Sorry for not replying early, sometimes I get too many messages in my mail and they get lost.


Does this error occurs to you every time or occasionally?

Did you try different servers?

Can you post a code that you use, so I could possible recreate this problem.




Apr 16, 2012 at 1:52 PM

Hi Oleg,


I have two servers to try it upon, the one on our side works fine after reducing buffer size. But our customer's server has this problem whenever the file size is bigger than the buffer size. They are also not very helpful so I am not able to ask them for tracing or any info. the code I use to upload is this:


               using (SftpClient sFtpClient = new SftpClient(hostname, port, username, password))
                    sFtpClient.BufferSize = 1024 * 28;
                    for (int i = 0; i < myArray.Count; i++)
                        using (System.IO.Stream stream = new System.IO.FileStream(myArray[i].ToString(), FileMode.Open))
                            sFtpClient.UploadFile(stream, myArray[i].ToString().Substring(myArray[i].ToString().LastIndexOf('\\') + 1), true);