Topic "Open session and log connection details"

Author Message
dvd.ribeiro
[View user's profile]

Joined: 2015-05-13
Posts: 2
Location: Portugal
Hi all, I'm trying to troubleshoot a session opening which gives me the following error:

"Message: Terminated by user.

at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.SessionElementLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForNonEmptyElementAndCreateLogReader(String localName, LogReadFlags flags)
at WinSCP.Session.Open(SessionOptions sessionOptions)"

The code I'm running is the following:

Code:
SessionOptions sessionOptions = new SessionOptions();
                    sessionOptions.Protocol = Protocol.Sftp;
                    sessionOptions.HostName = "sftp.stuff.com";
                    sessionOptions.UserName = "username";
                    sessionOptions.Password = "password";
                    sessionOptions.GiveUpSecurityAndAcceptAnySshHostKey = true;

                    using (Session session = new Session())
                    {
                        session.Open(sessionOptions);
                       
                        TransferOptions transferOptions = new TransferOptions();
                        transferOptions.TransferMode = TransferMode.Binary;
                        transferOptions.PreserveTimestamp = false;

                        TransferOperationResult transferResult;
                        transferResult = session.PutFiles("C:\localfile.txt", "sftp.stuff.com/remotepath/remotefile.txt", false, transferOptions);

                        transferResult.Check();
                    }



Am I missing something here?

I believe that enclosing all code inside using it closes and disposes the connection.

After this error I was able to upload files to server correctly. is there any way to enable and use WinScp logging to trace connection issues?

Thank you.
dvd.ribeiro
[View user's profile]

Joined: 2015-05-13
Posts: 2
Location: Portugal
Found out how to track session details:

Code:
using (Session session = new Session())
                        {
                            session.SessionLogPath = "Your full file Path here";
                            session.Open(sessionOptions);
                        }
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
dvd.ribeiro wrote:
Found out how to track session details:

Did it help you to resolve the problem?
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License