Skip to content

SSH.NET" Version=2020.0.0 #767

Description

@alona0610

Hi
I have a problem with SSH.Net 2020.0.0 When trying to SFTP file to Linux Server.
I am using .Net Core 3.1 under IIS.

The error that I am getting randomly is that the server is timing out.
Renci.SshNet.Common.SshOperationTimeoutException: Connection failed to establish within 30000 milliseconds.

Below is my code.
var connectionInfo = new RenciSftp.ConnectionInfo(this.FileServerHost,
this.FileServerUsername,
new RenciSftp.PasswordAuthenticationMethod(this.FileServerUsername, this.FileServerPassword));

 using (var client = new RenciSftp.SftpClient(connectionInfo))
{
try
{
client.Connect();
client.ChangeDirectory(remoteDir);
client.BufferSize = 4 * 1024; // bypass Payload error large files
using (var fileStream = fileStorage.GetFileStream(session))
{
client.UploadFile(fileStream, serverFilename);
}
}
catch (Renci.SshNet.Common.SshConnectionException ex)
{
this.AddUploadError("ERROR","SshConnectionException", hostName + "; " + IP, ex.ToString());
}
catch (System.Net.Sockets.SocketException ex)
{
this.AddUploadError("ERROR", "SocketException", hostName + "; " + IP, ex.ToString());
}
catch (Renci.SshNet.Common.SshAuthenticationException ex)
{
this.AddUploadError("ERROR","SshAuthenticationException", hostName + "; " + IP, ex.ToString());
}
catch (Exception ex)
{
this.AddUploadError("ERROR","General Error", hostName + "; " + IP, ex.ToString());
}
client.Disconnect();
client.Dispose();

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions