Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in .NET FTP by (220 points)
I'm receiving the following error when trying to connect to a remote FTP site:

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.Connect(EndPoint remoteEP)
at WebCamService.FtpClient.createDataSocket()
--- End of inner exception stack trace ---
at WebCamService.FtpClient.createDataSocket()
at WebCamService.FtpClient.Upload(String fileName, Boolean resume)
at WebCamService.FtpClient.Upload(String fileName)
at Xhibitnet.AssetProcessing.PackageAndDeploy.UploadArchive(String archiveFilePath, String teamName)


I suspect the problem is somehow related to passing through a firewall, but I'm not sure how to solve it.

My FTP Code works perfectly when transferring to a local FTP Server.
I can FTP to the remote server using the Windows command line FTP Client.

The machine running the edtftp component is Windows XP Pro with Service Pack 2 (with the firewall disabled).

The remote server is a Windows 2003 server.

Here is the code that fails:
_FileTransferClient.ConnectMode = FTPConnectMode.PASV;
_FileTransferClient.RemoteHost = remoteHost;
_FileTransferClient.Timeout = 5000;
_FileTransferClient.Connect();
_FileTransferClient.Login(remoteUsername, remotePassword);
string[] DirectoryList = _FileTransferClient.Dir(); // Exception occurs here


Finally, here are the logs from the FTP Component:
DEBUG [EnterpriseDT.Net.Ftp.FTPClient] 13 May 2005 14:57:20.963 : Connecting to 82.165.238.85:21
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:21.026 : 220 Microsoft FTP Service
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:23.635 : ---> USER ******
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:23.666 : 331 Password required for MagnetsFtp.
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:23.666 : ---> PASS ********
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:23.698 : 230 User MagnetsFtp logged in.
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:28.182 : ---> PWD
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:28.213 : 257 "/MagnetsFtp" is current directory.
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:31.120 : ---> PASV
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 13 May 2005 14:57:31.166 : 227 Entering Passive Mode (82,165,238,85,18,27).



Thanks for any suggestions on solving this problem,

Shawn.

1 Answer

0 votes
by (162k points)
Try using active mode rather than passive.

Categories

...