This project is read-only.

Issue when trying to connect using FtpWebRequest


Hi Richard,
I've followed the instructions you've provided and deploy the role on azure and I can connect to the role using coreFTP and filezilla. However, when I try to connect using the following code in a c# app I get a protocol error when I try to call reqFTP.GetResponse();
    FtpWebRequest reqFTP;
    reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://url of worker role "));
    reqFTP.Credentials = new NetworkCredential(userid , password);      
    reqFTP.UseBinary = true;
    reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
    reqFTP.Proxy = null;
    reqFTP.KeepAlive = false;
    reqFTP.UsePassive = false;
    response = reqFTP.GetResponse();
    reader = new StreamReader(response.GetResponseStream());
    string line = reader.ReadLine();
Digging around the message returned I get an error of "The remote server returned an error: (220) 220 FTP to Windows Azure Blob Storage Bridge Ready\r\n" However looking at your code this isn't an error and should allow me to proceed. Have you got any ideas on why this would be happening?
Thanks for building this in the first place, its a really useful tool to have.
All the best


richardparker wrote May 5, 2011 at 4:20 PM

Hi Steve

Change the UsePassive property to True:

reqFTP.UsePassive = true;

The FTP server currently only operates in active mode ;)

Hope this helps,


stevetrapps wrote May 5, 2011 at 5:01 PM

Thanks for this Richard,

I'm slightly confused though - as if I set reqFTP.UsePassive = true won't that set it to be passive mode and you've just said that it only operates in active mode? Or have I missed something?

I'll try it and let you know

All the best

richardparker wrote May 5, 2011 at 5:16 PM

Eek! Good spot - that's what I get for multitasking ;)

On second glance your code actually looks OK - it's configured for Active (which is the only mode supported).

Any chance you can send me the FTP server address for your installation so that I can test it using your code?

stevetrapps wrote May 6, 2011 at 10:39 AM

Hi Richard,

the code snippet you're after is
    reqFTP = (FtpWebRequest)FtpWebRequest.Create("");
    reqFTP.Credentials = new NetworkCredential("richardtest", "test");

richardparker wrote May 6, 2011 at 11:18 PM

Thanks Steve, I'll try this out on Sunday time permitting and get back to you ASAP.

g123 wrote Apr 3, 2012 at 7:37 AM

I got the following exception: "The remote server returned an error: (220) 220 Password ok, FTP server ready"

dbg00712 wrote Jun 25, 2012 at 7:54 PM

Hello Steve,
You could solve this problem? ... I'm having it at the moment.

thank you

dbg00712 wrote Jun 25, 2012 at 11:16 PM

Hi Richard,

I found the above problem, I had the same changing the code and decided to return the PasswordCommandHandler from 220 to 230.

Best Regards


wrote Feb 14, 2013 at 8:06 PM