markus_ja
markus_ja

Reputation: 2951

IdFtp.List throws socket-error #10054 occasionally

When I call the function

IdFtp.List(myList, '', false);

afterwards I have logged in and changed the ftp directory, I get a socket-error #10054 exception ("Connection reset by peer.") occesionally.

When I call that function e.g. 20 times consecutively I get that exception 1 time.

That problem I have only encountered on Vista OS.

Does anybody know what the problem is or how I can avoid it?

Upvotes: 4

Views: 7087

Answers (3)

In the component "IdFTP", change the following properties:

  • "Passive" = "False"
  • "TransferType" = "ftASCII"

Upvotes: 0

kobik
kobik

Reputation: 21252

Not much you can do about this, because the disconnection is done by the FTP server. You have a few choices:

  • Increase (or disable) the timeout settings (every FTP server has a different name for it) on your FTP Server connection settings.
  • Tell server that you are alive by sending NOOP command periodically (switching to Passive mode can also help).
  • Catch that exception and reconnect silently (This is my preferred solution because we have many FTP servers and I don't trust the sys-admins to change the FTP server time-out settings).

Here is a screen-shot from FileZilla FTP server time-out settings:

enter image description here

Note that with the above settings, the FTP client will be disconnected after 2 min of non-activity.
setting that value to 0, will disable the time-out.

Upvotes: 3

Remy Lebeau
Remy Lebeau

Reputation: 596582

The FTP protocol uses multiple socket connections. Every time you call List(), a new socket connection is established to transfer the requested listing data. It sounds like the FTP server is not always closing the socket correctly at the end of a transfer.

Upvotes: 2

Related Questions