Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
16.2k views
in .NET FTP by
Can someone help me understand why I'm intermitently getting the following error: "Unable to read data from the transport connection"?

Here's my code:

FTPClient ftp = new FTPClient("xxx.xxx");
try
{
ftp.Login("xxx", "xxx");
ftp.ConnectMode = FTPConnectMode.ACTIVE;
ftp.TransferType = FTPTransferType.BINARY;

try
{
ftp.Get(_dataDir + "agentsagents.log", "agentsagents.log");
}
catch(Exception E)
{
Trace.WriteLine("Error retrieving AgentsAgents.log: " + E.Message);
}
...
}
finally
{
ftp.Quit();
}

This code has been working well, but now it's popping up quite often -- but not always. I've upgraded to the latest version of edtFTP and I still get the same problem.

Thanks
Scott C.

9 Answers

0 votes
by
I now realize that the Transport Error was masking an error at a lower level. The first 1 or 2 transfers seem to work fine, but at some point the remote system isn't responding as edtFTP expects and never gets back in sync for the current session. Also notice the exception when Quit is called.

The remote server is Microsoft FTP Service.

The log below shows the details of my problem:

(3:11:42 PM) Command sent: ---> USER ******
(3:11:42 PM) Reply received: 331 Password required for ******.
(3:11:42 PM) Command sent: ---> PASS ********
(3:11:42 PM) Reply received: 230 User ****** logged in.
(3:11:42 PM) Command sent: ---> TYPE I
(3:11:42 PM) Reply received: 200 Type set to I.
(3:11:42 PM) Command sent: ---> PORT 192,168,1,100,9,26
(3:11:42 PM) Reply received: 200 PORT command successful.
(3:11:42 PM) Command sent: ---> RETR agentsagents.log
(3:11:42 PM) Reply received: 150 Opening BINARY mode data connection for agentsagents.log(541 bytes).
(3:11:42 PM) Reply received: 226 Transfer complete.
(3:11:42 PM) Command sent: ---> PORT 192,168,1,100,9,28
(3:11:56 PM) Error retrieving AgentsAgents.Zip: 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 RealtyAssociates.Updates.Updater.RetrieveListings() in c:\inetpub\wwwroot\realtyassoc\updater\updater.cs:line 86
(3:11:56 PM) Command sent: ---> PORT 192,168,1,100,9,30
(3:12:06 PM) Error retrieving OfficesOffices.log: 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 RealtyAssociates.Updates.Updater.RetrieveListings() in c:\inetpub\wwwroot\realtyassoc\updater\updater.cs:line 95
(3:12:06 PM) Command sent: ---> PORT 192,168,1,100,9,32
(3:12:17 PM) Error retrieving OfficesOffices.zip: 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 RealtyAssociates.Updates.Updater.RetrieveListings() in c:\inetpub\wwwroot\realtyassoc\updater\updater.cs:line 104
(3:12:17 PM) Command sent: ---> PORT 192,168,1,100,9,36
(3:12:27 PM) Error retrieving Daily_DataCIB.log: 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 RealtyAssociates.Updates.Updater.RetrieveListings() in c:\inetpub\wwwroot\realtyassoc\updater\updater.cs:line 113
(3:12:27 PM) Command sent: ---> PORT 192,168,1,100,9,38
(3:12:38 PM) Error retrieving Daily_DataCIB.zip: 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 RealtyAssociates.Updates.Updater.RetrieveListings() in c:\inetpub\wwwroot\realtyassoc\updater\updater.cs:line 122
(3:12:38 PM) Command sent: ---> PORT 192,168,1,100,9,40
(3:12:49 PM) Error retrieving Daily_DataLND.log: 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 RealtyAssociates.Updates.Updater.RetrieveListings() in c:\inetpub\wwwroot\realtyassoc\updater\updater.cs:line 131
(3:12:49 PM) Command sent: ---> PORT 192,168,1,100,9,42
(3:12:58 PM) Error retrieving Daily_DataLND.zip: System.IO.IOException: Unable to read data from the transport connection. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
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.
0 votes
by (162k points)
The first transfer succeeds, but the next does not. For some reason the server isn't responding to your second PORT command with a positive ack of 200. A bit weird. We know MS FTP works as we test against it.

I guess you could try using passive mode. Also examine the MS FTP logs to see if there are any clues there.

I now realize that the Transport Error was masking an error at a lower level. The first 1 or 2 transfers seem to work fine, but at some point the remote system isn't responding as edtFTP expects and never gets back in sync for the current session. Also notice the exception when Quit is called.

The remote server is Microsoft FTP Service.

The log below shows the details of my problem:

(3:11:42 PM) Command sent: ---> USER ******
(3:11:42 PM) Reply received: 331 Password required for ******.
(3:11:42 PM) Command sent: ---> PASS ********
(3:11:42 PM) Reply received: 230 User ****** logged in.
(3:11:42 PM) Command sent: ---> TYPE I
(3:11:42 PM) Reply received: 200 Type set to I.
(3:11:42 PM) Command sent: ---> PORT 192,168,1,100,9,26
(3:11:42 PM) Reply received: 200 PORT command successful.
(3:11:42 PM) Command sent: ---> RETR agentsagents.log
(3:11:42 PM) Reply received: 150 Opening BINARY mode data connection for agentsagents.log(541 bytes).
(3:11:42 PM) Reply received: 226 Transfer complete.
(3:11:42 PM) Command sent: ---> PORT 192,168,1,100,9,28
(3:11:56 PM) Error retrieving Agen
0 votes
by
I too am having the exact same problem. I tried every solution presented in these forums with no success. The behavior is very intermittent, making it very hard to trace the source or come up with a work around. I generally use this library in one of two locations. In one location the error is fairly rare. In the other I have to retry several times before all the files are successfully transferred.

Any other ideas?
0 votes
by (162k points)
We haven't been able to replicate this problem.

Do the FTP server logs tell you anything? I assume you are using IIS FTP?

I too am having the exact same problem. I tried every solution presented in these forums with no success. The behavior is very intermittent, making it very hard to trace the source or come up with a work around. I generally use this library in one of two locations. In one location the error is fairly rare. In the other I have to retry several times before all the files are successfully transferred.

Any other ideas?
0 votes
by
I have found the source of the problem. The connection was timing out. The documentation didn't specify and unit of measurement for the Timeout field in the FTPClient class. Appearently, it isn't in seconds. It seems one location was getting a much stronger connection to the FTP server than the other. I raised the value significantly and have since rarely seen the error.
0 votes
by (162k points)
Oops, we'd better make it a bit clearer that the timeout is milliseconds. Sorry about that.

I have found the source of the problem. The connection was timing out. The documentation didn't specify and unit of measurement for the Timeout field in the FTPClient class. Appearently, it isn't in seconds. It seems one location was getting a much stronger connection to the FTP server than the other. I raised the value significantly and have since rarely seen the error.
0 votes
by (560 points)
The first transfer succeeds, but the next does not. For some reason the server isn't responding to your second PORT command with a positive ack of 200. A bit weird. We know MS FTP works as we test against it.


Quick question Bruce - did you test against a MS FTP server running on "Windows 2000/2003 Server/Enterprise" versus a MS FTP "server" running on "Windows 2000/XP Professional/Workstation" ?

I am running into similar problems attempting multithreaded, ACTIVE mode transfers, and I am suspicious that the remote site is using professional/workstation - with its 10 simultaneous connection limit. But, I have no control over the remote site.
0 votes
by (162k points)
We test against MS FTP on XP Pro/Workstation, on a 10 MB LAN. Although our load test isn't a super load test, i.e. we don't test thousands of transfers.

A 10 connection limit on XP Pro/W would explain a lot for some people :(

The first transfer succeeds, but the next does not. For some reason the server isn't responding to your second PORT command with a positive ack of 200. A bit weird. We know MS FTP works as we test against it.


Quick question Bruce - did you test against a MS FTP server running on "Windows 2000/2003 Server/Enterprise" versus a MS FTP "server" running on "Windows 2000/XP Professional/Workstation" ?

I am running into similar problems attempting multithreaded, ACTIVE mode transfers, and I am suspicious that the remote site is using professional/workstation - with its 10 simultaneous connection limit. But, I have no control over the remote site.
0 votes
by (560 points)
We test against MS FTP on XP Pro/Workstation, on a 10 MB LAN. Although our load test isn't a super load test, i.e. we don't test thousands of transfers.
A 10 connection limit on XP Pro/W would explain a lot for some people :(


Thanks. The fun thing about that hard limit, is that it doesn't show up if you are testing against "localhost" on the same machine. It is only for "remote" connections.

This application will potentially be transfering thousands of files per day - but in small batchs of ~100 as the remote system gets updated. The initial snapshot and "fingerprint" run will be several thousand to get into sync, after that it won't be too bad.

Categories

...