IdFtp.List sometimes causes socket error # 10054

When i call the function

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

After that, I logged in and changed the ftp directory, I got socket exception # 10054 ("Connection reset by peer.") Occedionally.

When I call this function, for example. 20 times in a row I get this exception 1 time.

This is a problem that I encountered only in Vista.

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

+4
source share
3 answers

There is not much you can do because disconnection is done by the FTP server. You have several options:

  • Increase (or disable) the timeout settings (each FTP server has a different name for it) in the settings for connecting to the FTP server.
  • Inform the server that you are alive by periodically sending a NOOP command (switching to passive mode can also help).
  • Catch this exception and reconnect (this is my preferred solution because we have many FTP servers and I do not trust system administrators to change the FTP server timeout settings).

Here is a screenshot from FileZilla FTP server timeout settings:

enter image description here

Please note that with the above settings, the FTP client will be disconnected after 2 minutes of inactivity.
setting this value to 0 will disable the timeout.

+3
source

FTP uses several socket connections. Each time you call List() , a new socket connection is established to pass the requested listing data. It seems that the FTP server does not always properly close the socket at the end of the transfer.

+2
source

In the IdFTP component, change the following properties:

  • Passive = False
  • "TransferType" = "ftASCII"
0
source

Source: https://habr.com/ru/post/1403901/


All Articles