This project is read-only.

An established connection was aborted by the software in your host machine

Jun 27, 2012 at 10:27 PM

I have seen a couple posts on this.  I have the latest source from June 2012. 

 

ConnectionInfo connectionInfo = new PasswordConnectionInfo

(_ftpConnectionInfo.ServerName,_ftpConnectionInfo.ServerPort,_ftpConnectionInfo.ServerUserName,_ftpConnectionInfo.ServerPassword);

connectionInfo.Timeout =

new TimeSpan

(0, 0, 30, 0);

 

using (var client = new SftpClient

(connectionInfo))

{

client.Connect();

 

var fs = new FileStream(localFileName, FileMode.Create, FileAccess

.ReadWrite);

client.DownloadFile(remoteFileName, fs);

fs.Close();

client.Disconnect();

}

 

No matter what I do I get this error.  The funny thing is it still downloads the file. 

Jul 9, 2012 at 8:39 AM
Hello,

Same Error. Please Help. I have tried several things but nothing worked.

If I upload a very small file (few lines of txt file) works ok and the file gets uploaded correctly. Currently I am trying to upload 180KB and I get "An established connection was aborted by the software in your host machine". On the FTP server I can see the file but the length is zero.

My latest code looks like below:

On my trace I can see that it uploads up to 65436 bytes and then throws the exception.

 

  

Stream mStream = file.OpenBinaryStream();
if (mStream != null && mStream.Length > 0)
{
     ConnectionInfo connInfo = new PrivateKeyConnectionInfo(FTPServer, FTPPort, FTPUsername, new PrivateKeyFile(File.OpenRead(FTPkey)));
     connInfo.Timeout = TimeSpan.FromMinutes(30);
     using (SftpClient client = new SftpClient(connInfo))
     {
          if (!client.IsConnected)
          {
                 client.Connect();

           }

           client.BufferSize = 1024 * 32 - 50;
           SftpUploadAsyncResult result = client.BeginUploadFile(mStream, destUrl, Overwrite, null, null) as SftpUploadAsyncResult;

           while (!result.IsCompleted)
           {
                Helper.TraceWrite("Uploaded Bytes: " + result.UploadedBytes.ToString());
                //Thread.Sleep(100);
            }


            if (result.IsCompleted)
            {
                  ret = "Success";
                  client.EndUploadFile(result);

            }
                               
       }
  }
else
 {
      ret = "File not found.";
 }                           

 

 

 

Jul 11, 2012 at 6:45 AM

Any thoughts on this?

Coordinator
Jul 13, 2012 at 4:00 AM

Hi,

 

I actually never tested to work with regular FTP server, only with SFTP, so dont know why or how it works.

 

The reason you getting this error is because server terminates the connection for whatever reason.

So if you can set you server to run in debug mode to trace all information, it might give you a hint why it drops the connection.

 

Hope it helps.

 

Thanks,

Oleg

Jul 13, 2012 at 6:45 AM

Hi Oleg,

Thanks for the reply. Sorry I did not clarify but I do use SFTP server with a private key to connect.

So do you believe that something causes the SFTP server to drop the connection and not the application?

Thanks

Georgia

Coordinator
Jul 21, 2012 at 1:24 AM

Hi,

Sorry for late response.

Yes, I would suspect its server who drops the connection.

 

Thanks,

Oleg