SSH.NET: Renci.SshNet.Common.SshConnectionException: An established connection was aborted by the server
I 'm using Rencii package and it used to work however when I do List Directory which has got more than 2000 files, that is where it’s breaking and giving established connection was aborted.
using System;
using System.Collections.Generic;
using System.IO;
using Renci.SshNet;
namespace worship_sync
{
class Program
{
static void Main(string[] args)
{
const string host = "******";
const string username = "****";
const string password = "vagrant";
const string workingdirectory = "*****";
const string uploadfile = #"******";
Console.WriteLine("Creating client and connecting");
using (SftpClient client = new SftpClient(host, 8822, username, password))
{
client.Connect();
Console.WriteLine("Connected to {0}", host);
client.ChangeDirectory(workingdirectory);
Console.WriteLine("Changed directory to {0}", workingdirectory);
var listDirectory = client.ListDirectory(workingdirectory); // ERROR
Console.WriteLine("Listing directory:");
foreach (var fi in listDirectory)
{
Console.WriteLine(" - " + fi.Name);
}
}
}
}
}
AND I got this error when I am runing my code: Unhandled Exception: Renci.SshNet.Common.SshConnectionException: An established connection was aborted by the server.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (4 by maintainers)
To the people asking for updates, have you tried running your code in Visual Studio in Debug mode? You should see plenty SshNet.Logging debug messages in the Output pane (Show output from: Debug) if you have a debug build of the library attached to your solution. Please see here https://github.com/sshnet/SSH.NET/wiki/Troubleshooting-SSH.NET e.g.