Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.5k views
in .NET FTP by (180 points)
Hi,

I'm having a problem with the FTPConnection object. I'm pulling files in a loop from multiple directories happily from a GENE 6 FTP server (Win XP) when suddenly I receive the following error:

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

I tried setting the Timeout property to zero (meaning no timeout), but this doesn't seem to help. I restart the app and everything is working fine for a while.. then it gets the above error.

Is there anything I can do to prevent this?

I'm running in PASV mode and it seems to die in a different spot. Also, I checked the logs on the server and there isn't anything out of the ordinary when this goes down.

Thanks.
Jason

1 Answer

0 votes
by (51.6k points)
How many files have you transferred before this happens? Could it be that the server has run out of ports? One port is used on the client and one is used on the server for each file-transfer. After a port is closed it goes into a TIME_WAIT state for up to several minutes before it is released. This is a feature of TCP - not just FTP. If a lot of files are being transferred it's possible to run out of ports on either or both of the client and the server. In this case it is necessary to wait until a TIME_WAIT port is released.

Our PRO version has code for throttling multiple transfers in cases where this is a problem.

- Hans (EDT)

Categories

...