Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.2k views
in .NET FTP by (200 points)
I am getting this error:

The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established.

Here is my code:

FTPClient objFtp = new FTPClient();
objFtp.RemoteHost = ConfigurationSettings.AppSettings["CarsDotComRemoteHost"];
objFtp.Connect();
objFtp.ConnectMode = FTPConnectMode.PASV;
objFtp.Timeout = 90;

if (objFtp.Connected)
{
objFtp.Login(ConfigurationSettings.AppSettings["CarsDotComUser"], ConfigurationSettings.AppSettings["CarsDotComPassword"]);

...


It errors out on the Login line.

Any ideas????

4 Answers

0 votes
by (162k points)
You need to post the log file - see these forums for examples of enabling one.
0 votes
by (200 points)
DEBUG [HostNameResolver] 24 Aug 2007 08:27:09.462 : ftp.dmotorworks.com resolved to 66.45.71.221
DEBUG [FTPClient] 24 Aug 2007 08:27:09.462 : Connecting to 66.45.71.221:21
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:09.650 : 220 FTP Server ready.
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:09.650 : ---> USER DLR105299
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:09.744 : 331 User DLR105299 okay, need password.
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:09.744 : ---> PASS ********
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:09.822 : 230-You are user #50 of 250 simultaneous users allowed.
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.025 : 230-
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.025 : 230 Restricted user logged in.
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.041 : ---> PASV
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.087 : 227 Entering Passive Mode (66,45,71,221,204,216)
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.087 : Server supplied address=66.45.71.221
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.087 : Server supplied port=52440
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.087 : NewPassiveDataSocket(66.45.71.221,52440)
DEBUG [FTPControlSocket] 24 Aug 2007 08:27:10.181 : ---> STOR wex105299.txt
ERROR [FTPControlSocket] 24 Aug 2007 08:27:10.791 : Exception in SendCommand : System.IO.IOException: 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.
System.IO.IOException: 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.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
CAUSED BY:
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.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
ERROR [FTPClient] 24 Aug 2007 08:27:10.869 : Caught exception : System.IO.IOException: 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.
System.IO.IOException: 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.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
at EnterpriseDT.Net.Ftp.FTPClient.InitPut(String remoteFile, Boolean append)
at EnterpriseDT.Net.Ftp.FTPClient.PutASCII(Stream srcStream, String remoteFile, Boolean append, Boolean alwaysCloseStreams)
CAUSED BY:
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.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)



This time it logged in, then errored on the put command.
0 votes
by (200 points)
Never mind, I think I found the problem. The timeout value is set too low.
0 votes
by (162k points)
I've actually puzzled over something similar myself when the only problem was a very low timeout. Easy mistake to make!

Categories

...