Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

ted1122

Please find attached session log.
It turned out to be a confirmation about certificate was encountered and then failed.

When connected through GUI or from my desktop, this confirmation doesnt appear. (the GUI log doesnt say much other than the session name and time)

Thanks!
martin

Re: Connection failed error on Server 2012R2 (C# code)

Please attach a full session log file showing the problem (using the latest version of WinSCP). Log from successful GUI session would be helpful too.

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.
ted1122

Connection failed error on Server 2012R2 (C# code)

Hi,

I have recently wrote a simple C# code that connects to our FTP server and download files using WinSCP library.
Everything works great in our local dev machine but when I move it to the server, the code start throwing exception when opening a new connection.

The exception is as follows:

Connection failed.
at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.Session.Open(SessionOptions sessionOptions)


The server is running Windows Server 2012R2 (a virtual machine on Hyper V)
WinSCP version is 5.52 (dll and standalone .exe)

The code is very similar to the example code at https://winscp.net/eng/docs/library_session_getfiles#example
Heres the code snippet that I used to initiate a session:
private Session _session = null;


public FTPSession()
{
    if (_session == null)
    {
        _session = new Session();
        _session.ExecutablePath = Settings.WINSCP_EXE;
        _session.Open(Options);               
    }
}

private SessionOptions Options
{
    get
    {
        return new SessionOptions
        {
            Protocol = Protocol.Ftp,
            HostName = Settings.FTP_Host, //read from config file
            UserName = Settings.FTP_UserName, //read from config file
            Password = Settings.FTP_Password, //read from config file
            Timeout = TimeSpan.FromSeconds(Settings.FTP_TimeOut), //read from config file
            FtpSecure = (Settings.FTP_SSL) ? FtpSecure.ExplicitSsl : FtpSecure.None //read from config file
        };
    }
}


I could connect to the FTP server successfully through GUI (on the server). I tried to add exception to the FireWall, raise account permissions etc but all didnt work...
Is there anything else that might have caused this issue?
Much appreciated with the help!!