I noticed that I was failing to get the directory listing from some FTP servers.
At first I thought it was just related to firewalls/routers/some weird aspect of my network setup. (I am testing my app on a VM).
some FTP servers do not respond to the "LIST" command until the connection to the second (PASV) port has been made.
Commenting the call to controlComplexSocket.Receive() after the LIST has been sent resolves the issue:
// send LIST/MLSD/MLST-command via control socket
{
var success = controlComplexSocket.Send(concreteCommand,
this.Encoding,
this.SendTimeout);
if (!success)
{
return Enumerable.Empty<FtpListItem>();
}
}
//NOTE: some FTP servers don't send a 150 response to the LIST command until the 2nd socket has connected!
//{
// var complexResult = controlComplexSocket.Receive(this.Encoding,
// this.ReceiveTimeout);
// var success = complexResult.Success;
// if (!success)
// {
// return Enumerable.Empty<FtpListItem>();
// }
//}