1
Vote

Issue when trying to connect using FtpWebRequest

description

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
Steve

comments

richardparker wrote May 5, 2011 at 3: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,

Richard.

stevetrapps wrote May 5, 2011 at 4: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
Steve

richardparker wrote May 5, 2011 at 4: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 9:39 AM

Hi Richard,

the code snippet you're after is
    reqFTP = (FtpWebRequest)FtpWebRequest.Create("ftp://ftp0505.cloudapp.net:21");
    reqFTP.Credentials = new NetworkCredential("richardtest", "test");
Thanks
Steve

richardparker wrote May 6, 2011 at 10: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 6: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 6:54 PM

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

thank you

dbg00712 wrote Jun 25, 2012 at 10: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

David.

wrote Feb 14, 2013 at 7:06 PM