Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.3k views
in .NET FTP by (620 points)
I was downloading a file when this message popped up on my screen.

[quote]Unhandled Exception: System.IO.IOException: Unable to read data from the transport connection. ---> 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[/quote]

I figure this means that I lost my connection, but i don't know for sure. Any help with the meaning of this?

This is an unmanned ftp session that runs at the same time every day. When this message comes up, it stops execution till you clear the dialoge. Is there a way to tell the program to reconnect and continue?
:?: :?: :!:

6 Answers

0 votes
by (161k points)
Most likely the host is not reachable or didn't respond when you attempted connection.

You will need to write the code to reconnect if this exception is caught.

I figure this means that I lost my connection, but i don't know for sure. Any help with the meaning of this?

This is an unmanned ftp session that runs at the same time every day. When this message comes up, it stops execution till you clear the dialoge. Is there a way to tell the program to reconnect and continue?
:?: :?: :!:
0 votes
by (620 points)
Thanks for the response Bruce.

I have this enclosed in a try catch block, but the exception seems to happen outside the bounds of my code. I am not sure how else to handle this.

I have been testing the connection by looking for specific responses and reconnecting if the correct response is not returned. Is there a better way to test the connection in the newer version?
0 votes
by (161k points)
Just catch Exception when connecting. If no exception is thrown, the connection was successful.

Thanks for the response Bruce.

I have this enclosed in a try catch block, but the exception seems to happen outside the bounds of my code. I am not sure how else to handle this.

I have been testing the connection by looking for specific responses and reconnecting if the correct response is not returned. Is there a better way to test the connection in the newer version?
0 votes
by (620 points)
There in lies the problem. The connection was successful. I was about two thrids of the way through my download list when this messagebox popped up. I have my application written as a console app with no user input required so that it will run until finished. It connects just fine and starts to transfer files but every once in a while it gets a Socket level exception during the get method that it says is not handled, even though the call to the get method is enclosed in a try-catch block.
0 votes
by (161k points)
Perhaps you can isolate it to a smallish chunk of code and post it here.

There in lies the problem. The connection was successful. I was about two thrids of the way through my download list when this messagebox popped up. I have my application written as a console app with no user input required so that it will run until finished. It connects just fine and starts to transfer files but every once in a while it gets a Socket level exception during the get method that it says is not handled, even though the call to the get method is enclosed in a try-catch block.
0 votes
by
Here is the full syntax of the Exception. If you look toward the bottom, it is occurring during the FTPClient.Get() call inside the CNFTP2.downLoadFiles() function. I will post the code below.

System.IO.IOException: Unable to read data from the transport connection. ---> 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)
--- End of inner exception stack trace ---
at EnterpriseDT.Net.Ftp.FTPClient.InitGet(String remoteFile)
at EnterpriseDT.Net.Ftp.FTPClient.GetBinary(String localPath, String remoteFile)
at EnterpriseDT.Net.Ftp.FTPClient.Get(String localPath, String remoteFile)
at CNFTP2.CNFTP2.downLoadFiles()

Here is the code:
try
{
Console.WriteLine( " Downloading File -> " + remoteFile.Name );
this.ftpClient.Get( localfile, remoteFile.Name );
if( File.Exists( localfile ) )
{
this.ftpClient.Delete( remoteFile.Name );
}
}

Categories

...