Open session and log connection details

Advertisement

dvd.ribeiro
Joined:
Posts:
2
Location:
Portugal

Open session and log connection details

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:

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.

Reply with quote

dvd.ribeiro
Joined:
Posts:
2
Location:
Portugal

Found out how to track session details:

using (Session session = new Session())
                        {
                            session.SessionLogPath = "Your full file Path here";
                            session.Open(sessionOptions);
                        }    

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,253
Location:
Prague, Czechia

dvd.ribeiro wrote:

Found out how to track session details:
Did it help you to resolve the problem?

Reply with quote

Advertisement

You can post new topics in this forum