1

We are using Cerberus FTP server. And for the client I am using SSH.NET library to connect to server and upload a file. I was able to connect and upload files to FTP server without issue most of the time.

However when destination path does not exists on the FTP server, the SSH.NET library throws exception as expected. However Exception's Message property is empty.

var sftpClient = new SftpClient(host,username,password);
sftp.connect();
var destination = "SomeInvalidPath\myfile.txt"
using (var fs = new FileStream(sourceFilePath, FileMode.Open, FileAccess.Read))
{
      try
      {
         sftp.UploadFile(fs, destination);                        
      }
      catch (Exception ex)
      { 
         // ex.Message is empty ???
         Logger.Current.Error(ex, "Error while FTP");             
      }                
}

Not sure if this SSH.NET library issue or FTP server needs to propagate errors back to client?

Update 1

Stack trace

" at Renci.SshNet.Sftp.SftpSession.RequestOpen(String path, Flags flags, Boolean nullOnError)\r\n at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, Flags flags, SftpUploadAsyncResult asyncResult, Action1 uploadCallback)\r\n at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Action1 uploadCallback)\r\n at XXXXXX

JIST
  • 1,139
  • 2
  • 8
  • 30
LP13
  • 30,567
  • 53
  • 217
  • 400
  • The exception comes from the .NET library. If the message is null or empty, I'd consider that a bug. – mason Oct 26 '18 at 22:21
  • 1
    We had the same issue, SSH.NET lib trying to upload a file to Cerberus, but in our case, the user didn't had permissions for that - result is an exception without any error description. We are also looking for a solution. – Carlos Oliveira Apr 18 '19 at 17:10

0 Answers0