c# app FTP error : "227 Entering Passive Mode"

14.9k Views Asked by At

I can't figure this problem out I'm having at a client's site. The client has two sites and both run the same version of my app. At one site there are no problems but at the other I started to consistently get the following error when trying to download files from a FTP site:

"227 Entering Passive Mode (...)"

I've been reading on SO and Google and cannot figure out the problem. I want to drop this client because they are just costing money. I'm using the FTP functionality included in .NET 3.5.

Any clue as to what could be going on?? Network security changes on their end?

4

There are 4 best solutions below

0
On BEST ANSWER

Test with a client ftp but only in ACTIVE MODE.

Deactivate this: in Tools - internet options - advanced - "Use passive FTP (for firewall and DSL modem )"

0
On

A firewall issue when dropping into a passive-mode port? Can you connect to the FTP server with Filezilla?

0
On

Your probably getting a timeout, did you check the firewall? it could be blocking your connection.

0
On

To avoid that error, just use reqFTP.UsePassive = false;

reqFTP.UsePassive = false;

Check below

                FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://127.0.0.1/1542");
                ftpRequest.Credentials = new NetworkCredential("6584", "123456");
                ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
                ftpRequest.UsePassive = false;
                FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
                StreamReader streamReader = new StreamReader(response.GetResponseStream());

                List<string> directories = new List<string>();

                string line = streamReader.ReadLine();
                while (!string.IsNullOrEmpty(line))
                {
                    directories.Add(line);
                    line = streamReader.ReadLine();
                }

                streamReader.Close();
                return true;