I've been able to connect to an FTP Server in Active mode through FileZilla, but unable to do the same with the .NET FTP library.
Here's my code:
_FtpConnection =
new FTPConnection
{
ServerAddress = ftpSite.FtpSite,
UserName = ftpSite.FtpUserID,
Password = ftpSite.FtpPassword,
Timeout = 10000,
ConnectMode = FTPConnectMode.ACTIVE,
PublicIPAddress = "my public ip"
};
_FtpConnection.ActivePortRange.LowPort = "6000";
_FtpConnection.ActivePortRange.HighPort = "6001";
_FtpConnection.ServerDirectory = "server directory";
_FtpConnection.Connect();
var files = _FtpConnection.GetFileInfos();
_FtpConnection.Close();
Here's my log file. I've edited a few things to hide data. The remote IP has been replaced with "11.11.111.11", and my public IP in the PORT command has been replaced with "222,222,2,222".
DEBUG [FTPConnection] 6 Nov 2014 07:58:23.207 : Set LocalDirectory='C:\Windows\SysWOW64\inetsrv'
DEBUG [FTPClient] 6 Nov 2014 07:58:23.207 : Connecting to ftp.companyname.com:21
DEBUG [HostNameResolver] 6 Nov 2014 07:58:23.207 : Resolving ftp.companyname.com
DEBUG [HostNameResolver] 6 Nov 2014 07:58:23.363 : ftp.companyname.com resolved to 11.11.111.11
INFO [BaseSocket] 6 Nov 2014 07:58:23.363 : Connecting to 11.11.111.11:21 with timeout 10000 ms
DEBUG [BaseSocket] 6 Nov 2014 07:58:23.441 : Successfully connected to 11.11.111.11:21
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.441 : Setting socket timeout=10000
INFO [FTPControlSocket] 6 Nov 2014 07:58:23.441 : Command encoding=System.Text.SBCSCodePageEncoding
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.441 : SetActivePortRange(6000,6001). NextPort=6000
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.441 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.519 : 220 (vsFTPd 2.2.2)
DEBUG [FTPConnection] 6 Nov 2014 07:58:23.534 : Connected to ftp.companyname.com (instance=0)
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.534 : ---> USER my_username
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.612 : 331 Please specify the password.
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.612 : ---> PASS ********
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.706 : 230 Login successful.
DEBUG [FTPConnection] 6 Nov 2014 07:58:23.706 : Successfully logged in
INFO [FTPConnection] 6 Nov 2014 07:58:23.706 : Auto FEAT disabled
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.706 : ---> TYPE I
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.784 : 200 Switching to Binary mode.
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.800 : ---> CWD out
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.878 : 250 Directory successfully changed.
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.878 : ---> PWD
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.956 : 257 "/out"
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:23.956 : ---> SYST
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.034 : 215 UNIX Type: L8
DEBUG [FTPFileFactory] 6 Nov 2014 07:58:24.034 : Selected UNIX parser
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.034 : ---> PWD
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.112 : 257 "/out"
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.112 : NewActiveDataSocket(6000)
INFO [FTPControlSocket] 6 Nov 2014 07:58:24.112 : Forcing use of fixed IP for PORT command
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.112 : ---> PORT 222,222,2,222,23,112
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.190 : 200 PORT command successful. Consider using PASV.
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.190 : Next active port will be: 6001
DEBUG [FTPControlSocket] 6 Nov 2014 07:58:24.190 : ---> LIST
ERROR [FTPControlSocket] 6 Nov 2014 07:58:34.694 : Read failed ('' read so far)
ERROR [FTPControlSocket] 6 Nov 2014 07:58:34.694 : Exception in SendCommand
ERROR [FTPControlSocket] 6 Nov 2014 07:58:34.694 : EnterpriseDT.Net.Ftp.ControlChannelIOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
ERROR [FTPControlSocket] 6 Nov 2014 07:58:34.694 : at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadLine()
ERROR [FTPControlSocket] 6 Nov 2014 07:58:34.694 : at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
ERROR [FTPControlSocket] 6 Nov 2014 07:58:34.694 : at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
Any ideas what I'm doing wrong here, or why I can't connect?