<p>Background: We are programmatically transferring files to an SFTP site that our company does not manage. Previously, we encountered an issue in which larger files would only partially upload to the site; this is not within the scope of this issue, but it will explain why we set our BufferSize property to 1024 * 8.</p>
<p> </p>
<p>Issue: Our file (723kb) uploads to the server successfully. However, we receive an SshException immediately afterward stating "Connection was lost". This is thrown before we can call our SftpClient.Disconnect() method; when we do call it, a second SocketException is thrown. "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied".</p>
<p> </p>
<p>Notes:</p>
<p> - The log is attached as a .txt file.</p>
<p> - Server/Host name has been redacted for confidentiality purposes. We do not have administrative access to this server.</p>
<p> - I added a bit of extra logging. Namely, I show the value of the BufferSize property, and when SendMessage() is called, I add messageData.Length to the log.</p>
<p> - This uses the latest source code as of today.</p>
<p> </p>
<p>If you need more information please let me know.</p>
<p> </p>
<p>UPDATE 2012/10/01 - After doing more research, I noticed that we were sending a lot more messages than we were receiving from the server. I am led to believe this is due to their server being unable to handle the large packet sizes effectively. I modified my packet size to 1kb and have been able to successfully upload the larger files with only a negligible (if any) performance hit.</p>
Comments: ** Comment from web user: olegkap **
<p> </p>
<p>Issue: Our file (723kb) uploads to the server successfully. However, we receive an SshException immediately afterward stating "Connection was lost". This is thrown before we can call our SftpClient.Disconnect() method; when we do call it, a second SocketException is thrown. "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied".</p>
<p> </p>
<p>Notes:</p>
<p> - The log is attached as a .txt file.</p>
<p> - Server/Host name has been redacted for confidentiality purposes. We do not have administrative access to this server.</p>
<p> - I added a bit of extra logging. Namely, I show the value of the BufferSize property, and when SendMessage() is called, I add messageData.Length to the log.</p>
<p> - This uses the latest source code as of today.</p>
<p> </p>
<p>If you need more information please let me know.</p>
<p> </p>
<p>UPDATE 2012/10/01 - After doing more research, I noticed that we were sending a lot more messages than we were receiving from the server. I am led to believe this is due to their server being unable to handle the large packet sizes effectively. I modified my packet size to 1kb and have been able to successfully upload the larger files with only a negligible (if any) performance hit.</p>
Comments: ** Comment from web user: olegkap **
As I was reading thru other people problem it might be a buffer size issue.
Look at this issue.
Ty to set buffer size to something smaller and see if files are transferred.
So it might be that remote server closes the connection because it received a bigger packet that expected.
Thanks,
Oleg