Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3k views
in .NET FTP by (120 points)
I am using edtftp as ftp client.
I can connect but when I try to list directory or get the file, an exception as following:
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 EnterpriseDT.Net.StandardSocket.Connect(EndPoint remoteEP)
at EnterpriseDT.Net.Ftp.FTPControlSocket.NewPassiveDataSocket(String ipAddress, Int32 port)
at EnterpriseDT.Net.Ftp.FTPControlSocket.CreateDataSocketPASV()
at EnterpriseDT.Net.Ftp.FTPControlSocket.CreateDataSocket(FTPConnectMode connectMode)
at EnterpriseDT.Net.Ftp.FTPClient.Dir(String dirname, Boolean full)
at DiamondDBImporter.Ftp.GetFile(String localFileName, String remoteFileName

And here is my code:
ftp = new FTPClient(host);

// login
log.Debug("log in");
ftp.Login(user, password);
// set up passive ASCII transfers
log.Debug("Setting up passive, ASCII transfers");
ftp.ConnectMode = FTPConnectMode.PASV;
ftp.TransferType = FTPTransferType.ASCII;
// get directory and print it to console
log.Debug("Directory:");
string[] files = ftp.Dir(".", true);
for (int i = 0; i < files.Length; i++)
log.Debug(files[i]);
// copy file from server
log.Info("Getting file");
ftp.Get(localFileName, remoteFileName);
// Shut down client
log.Info("Quitting client");
ftp.Quit();

1 Answer

0 votes
by (162k points)
Try active mode, some firewalls are configured to allow this and not passive.

I am using edtftp as ftp client.
I can connect but when I try to list directory or get the file, an exception as following:
System.Net.Sockets.SocketException: A connection attempt failed

Categories

...