FTP Proxy

Aug 10, 2012 at 6:00 PM
Edited Aug 10, 2012 at 6:00 PM

Hello, first of all, thank you for this library, i've used it, works great and is very flexible.

I write just to tell that I'm using it with a FTP proxy that is not implemented, and how I'm using it. It's a "FTP proxy" that works just like a FTP server with a different authentication mode. I connect to the proxy and provide the final host in the USER command, the the proxy connects to the final host and forwards my commands and it's anwers.

The proxy brand is bluecoat, here is some info: https://hypersonic.bluecoat.com/doc/437

For example, if I want to connect to ftp.myserver.com throught ftp.myproxy.com (

  1. Client (Me) Connects with
  2. Client sends USER myserveruser@ftp.myserver.com prxuser
  3. Client sends PASS ****** (proxy pass)
  4. Client sends ACCT ****** (ftp.myserver.com pass)
  5. I'm connected, now I can talk to the proxy just like I would with the server

I did it controlling manually the connection process:


ftp.Connect(ProxyHost, ProxyPort);
ftp.Execute(string.Format("USER {0}@{1} {2}", User, Host, ProxyUser));
if (ftp.ResponseCode == "331")
    ftp.Execute(string.Format("PASS {0}", Password));
    throw new Exception("Authentication FTP Error: " + ftp.ResponseMessage);
if (ftp.ResponseCode == "332")
    ftp.Execute(string.Format("ACCT {0}", ProxyPassword));
    throw new Exception("Authentication FTP Error: " + ftp.ResponseMessage);
if (ftp.ResponseCode != "230")
    throw new Exception("Authentication FTP Error: " + ftp.ResponseMessage);



Aug 15, 2012 at 2:00 PM

Thanks for sharing this information. FYI, rather than checking for an exact completion code you might just test the type of code that you received. The first digit in the completion code (or ResponseCode) above indicates success or failure. 1 - 3 are successful responses, 4 and 5 are errors. The reason I mention it is because the exact completion code could vary from server to server. For maximum portability it's (in my opinion of course) better to branch your code based on the first digit. The following page in the documentation section of this site also talks about the completion codes and extending System.Net.FtpClient:


Anyway, thanks for taking the time to post about how you're using this project.

Aug 15, 2012 at 2:05 PM

I added a link to this discussion in the documentation section for others who might be in similar situations.

Feb 7, 2013 at 8:21 AM

Thank you for the FTP API, it worked like a charm, until I tested it with the ftp proxy. I followed this post and tried to execute few commands. Commands like CWD, PWD, are executed successfully. But when I tried to use the command RETR (RETR file.xml) to retrieve a file, I am receiving the following response.

Code: 125
Message: Data connection already open; Transfer starting.
ResponseType: PositivePreliminary
Success: True

The file is not transferred.