I have the following code that attempts to connect to an FTP server...
ftpConnection = new FTPConnection();
ftpConnection.UserName = myUsername;
ftpConnection.Password = myPassword;
ftpConnection.ServerAddress = myHost;
#if DEBUG
FTPConnection.LogFile = "Ftp.log";
FTPConnection.LogLevel = EnterpriseDT.Util.Debug.LogLevel.Debug;
#endif
try
{
ftpConnection.ConnectMode = FTPConnectMode.PASV;
ftpConnection.Login();
string[] files = ftpConnection.GetFiles();
testConfig.ConnectMode = testConfig.ConnectMode;
}
...
...and when I execute it, I get the following information in my Ftp.log file:
DEBUG [HostNameResolver] 25 Sep 2007 16:37:32.428 : myhost.net resolved to xxx.xxx.187.153
DEBUG [FTPClient] 25 Sep 2007 16:37:32.443 : Connecting to xxx.xxx.187.153:21
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.521 : 220 Microsoft FTP Service
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.521 : ---> USER myUsername
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.568 : 331 Password required for ryexley.
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.568 : ---> PASS ********
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.615 : 230 User myUsername logged in.
DEBUG [FTPConnection] 25 Sep 2007 16:37:32.615 : Successfully logged in
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.615 : ---> TYPE I
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.662 : 200 Type set to I.
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.662 : ---> PWD
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.709 : 257 "/myRootDirectory" is current directory.
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.709 : ---> PASV
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.740 : 227 Entering Passive Mode (xxx,xxx,187,153,8,52).
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.740 : Server supplied address=xxx.xxx.187.153
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.740 : Server supplied port=2100
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.740 : Substituting server supplied IP (xxx.xxx.187.153) with remote host IP (xxx.xxx.187.153)
DEBUG [FTPControlSocket] 25 Sep 2007 16:37:32.756 : NewPassiveDataSocket(65.185.187.153,2100)
ERROR [FTPControlSocket] 25 Sep 2007 16:37:53.772 : Failed to create connecting socket : System.Net.Sockets.SocketException: 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
System.Net.Sockets.SocketException: 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
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at EnterpriseDT.Net.StandardSocket.Connect(EndPoint remoteEP)
at EnterpriseDT.Net.Ftp.FTPControlSocket.NewPassiveDataSocket(String ipAddress, Int32 port)
When I step through the code in the debugger, it seems to be this line that its failing on:
string[] files = ftpConnection.GetFiles();
So it seems to me like actually *connecting* to the server isn't the problem, but when I actually try to get some information from the server, seems like that's when the problems start. Not sure why.
Anybody have any idea what's wrong here? I can connect to the same server with the same credentials from the windows command line with no problems at all, so obviously it works from the machine that I'm testing it on. There must be something that I'm missing in my code to enable this to work somehow. Any ideas?