0 votes
by (120 points)

My Code(few data are intentionally changed as "xxx.." for security reason ):-

public void SFtp_Connect()
{

        Sftp sftp = new Sftp();
        //sftp.Connect("xxx.xxx.x.xx", 22);
        //sftp.Login("xxx", "xxx");

        ////string sourceFilePath = @"C:\testFile\";
        //string sourceFilePath = @"C:\test_ftp\ExportList";
        //string targetPath = @"Test_Sftp";
        //string targetFilename = "";

        //sftp.Connect("xxx.xxx.com", 22);
        //sftp.Login("xxx", "xxx");

        sftp.Connect("xx.xxx.xx.xx", 22);
        sftp.Login("xxx", "xxx");

        string sourceFilePath = @"C:\Test\ExportList";
        string targetPath = @"/out/reports";
        string targetFilename = "";

        try
        {

            foreach (string UploadFile in Files)
            {
                //if (!sftp.DirectoryExists(targetPath))
                    //sftp.CreateDirectory(targetPath);

                sourceFilePath = sourceFilePath + "\\" + UploadFile;
                targetFilename = targetFilename + UploadFile;

                sftp.GetFile(sourceFilePath, UploadFile);                    
                //sftp.PutFile(sourceFilePath, targetPath + "/" + targetFilename);                   
            }
        }
        catch (Exception e)
        {
            throw e;
        }

        sftp.Disconnect();
    }

Error I got :-

2/23/2017 2:49:47 PM : Error on load, Error: Error while sending packet.. Inner Exception:Rebex.Net.SshException: Error while sending packet. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Rebex.Net.ProxySocket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Rebex.Net.SshSession.clmbOg(BBdsJfZ , Boolean )
--- End of inner exception stack trace ---
at Rebex.Net.SshSession.clmbOg(BBdsJfZ , Boolean )
at Rebex.Net.SshSession.CgoKrJZ()
at Rebex.Net.SshSession.cCIjvV(String , String , SshPrivateKey , SshGssApiCredentials )
at Rebex.Net.SshSession.Authenticate(String userName, String password, SshPrivateKey privateKey)
at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey). StackTrace: at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey)
at xxx.Form1.SFtpConnectxxx() in d:\Projects\xxx\xxx\xxx\Form1.cs:line 216
at xxx.Form1.Form1_Load(Object sender, EventArgs e) in d:\Projects\xxx\xxx\xxx\Form1.cs:line 103

Applies to: Rebex SFTP

1 Answer

0 votes
by (70.2k points)

Does the error occurs every time you try to login or occasionally?

Can you please post here or send us (to support@rebex.net) the communication log for analysis?

It can be created like this:

sftp.LogWriter = new Rebex.FileLogWriter(@"c:\Test\log.txt", Rebex.LogLevel.Debug);
by (120 points)
this occurs every time we tried to establish connection with sftp server. exception occurs at the of getfile and putfile() call.

Below is the communication log :-
----------------------------------------------------------
2017-02-23 16:22:29.950 INFO Sftp(1) Command: SSH_FXP_STAT (2, '/out/reports')
2017-02-23 16:22:30.271 INFO Sftp(1) Response: SSH_FXP_ATTRS (2)
by (70.2k points)
It seems you are trying to download a directory '/out/reports' but you are calling the sftp.GetFile method. Is it correct?
...