简体   繁体   中英

Unable to connect to FTP Server with SOCKS5 using WinSCP

I choose WinSCP so I can implement a SOCKS5 Proxy into my FTP Client. With the Proxy commented out I am able to connect and download files from a FTP Server without a proxy. If I try to connect to the FTP Server with SOCKS5 Proxy I am unable to connect. Any erros in my proxy configuration or something ? LoginData is correct, works with filezilla.

public void Download(string LocalFile)
    {
        try
        {
            // Setup session options              
            SessionOptions sessionOptions = new SessionOptions
            {
                Protocol = Protocol.Ftp,
                HostName = LoginData.Servername,
                UserName = LoginData.Username,
                Password = LoginData.Passwort,
            };

            // Configure proxy
            sessionOptions.AddRawSettings("ProxyMethod", "2"); // socks5 proxy
            sessionOptions.AddRawSettings("ProxyHost", "***"); //host ip
            sessionOptions.AddRawSettings("ProxyPort", "***"); //Port
            sessionOptions.AddRawSettings("ProxyUsername", "***"); //Username
            sessionOptions.AddRawSettings("ProxyPassword", "***"); //Password

            using (Session session = new Session())
            {
                session.DisableVersionCheck = true;

                // Connect
                session.Open(sessionOptions);

                // Download files
                TransferOptions transferOptions = new TransferOptions();
                transferOptions.TransferMode = TransferMode.Binary;

                TransferOperationResult transferResult;
                transferResult =
                    session.GetFiles(LoginData.RemoteFile, LocalFile, false, transferOptions);

                // Throw on any error
                transferResult.Check();

                // Print results
                foreach (TransferEventArgs transfer in transferResult.Transfers)
                {
                    Console.WriteLine("Download of {0} succeeded", transfer.FileName);
                }
            }

        }
        catch (Exception e)
        {
            Console.WriteLine("Error: {0}", e);
        }
    }

With FileZilla, your proxy host is socks.cgm.ag - CGM

With WinSCP, your proxy host is socks.cmg.ag - CMG

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM