Closed
Description
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
Labels
No labels