425 Can't open data connection.

425 Can't open data connection.

I get this error on some ftpservers. not all. I have a loop that connects and checks dirs on 4-5 ftpservers. on a few I get "425 Can't open data connection." since I can get on to some servers it must be some setting in the library that I miss. When I try to connect to the same ftps with the SmartFTP Client I succeed. I also succeed when I try other ftp libraries. (coding c# .NET)

I can't find a solution to this problem on this forum so I was forced to make a new topic. There must be some line of code that I'm missing.

// Load License Key
sfFTPLib.Global global = new sfFTPLib.Global();
if (global.LoadLicenseKeyData("xxx"))
System.Console.WriteLine("");

// Create an instance of the Ftp class.
FTPConnectionMTA ftp2 = new FTPConnectionMTA();

ftp2.Host = iphost;
ftp2.Port = Convert.ToInt32(port);
ftp2.Username = username;
ftp2.Password = password;
ftp2.LogFile = "ftp.log";
ftp2.Passive = true;

ftp2.DataProtection = enumDataProtection.ftpDataProtectionPrivate;

if (secureSSL == 1)
{
ftp2.Protocol = enumProtocol.ftpProtocolSSLExplicit;
}

sfFTPLib.enumError err = ftp2.Connect();

if (err == sfFTPLib.enumError.ftpErrorSuccess)
{

ftp2.ChangeDirectory(changeToDir);


Console.WriteLine(iphost + " " + ftp2.LastReply.ToString());


if (ftp2.ReadDirectory() == sfFTPLib.enumError.ftpErrorSuccess)
{
FTPDirectory ftpDirectory = ftp2.Directory;

int check = 0;

// Use the foreach statement to iterate through
// elements in the collection
foreach (FTPItem objItem in ftpDirectory)
{
System.Console.WriteLine("Type={0}; Name={1}; Size={2}", objItem.Type, objItem.Name, objItem.Size);

if (objItem.Type.ToString() == "ftpItemTypeFolder")
{
prestatus += siteName + ": " + objItem.Name + Environment.NewLine;
Application.DoEvents();
check = 1;
}
}

if (check == 0)
{
prestatus += siteName + ": No Releases Listed" + Environment.NewLine;
Application.DoEvents();
}
}

System.Console.WriteLine("Status: {0}", ftp2.LastReply.ToString());

ftp2.Disconnect();
}
else
{
System.Console.WriteLine("Connect() failed. LastError = {0}", ftp2.LastError);
}

I get no results on the "errored" site in the ftp.log, only the ones that succeed with dir listing are entered in the log.

Please, give a helping hand.





EDIT:

I fixed it myself. Here is the solution for all those who might get the same error.


I added:


ftp2.LISTOption = 6;
ftp2.PassiveForceIP = false;