[Background]
The xceedftp FTP component is used in our project to download data. However, due to the large number of files, the cards may die from time to time during each download process,
If no exception is thrown, It is stuck in the receivefile method. I have tried many methods, but it has not been solved for a long time.
[Solution]
When I tried to modify this bug today, I just changed the FTP MODE to take the initiative to solve it... it was so depressing at the time...
_ Oftp. passivemode = false;
This problem has not been stuck for more than 10 tests in the LAN for the time being. We will try again after the public network test ends.
The reason is that I am not very familiar with the principles of FTP. By the way, I would like to add the difference between active and passive FTP modes.
Http://www.moon-soft.com/program/bbs/readelite1095089.htm
[Ftp mode]
Active FTP and Passive FTP)
In active mode, the FTP client starts a random connection from Port n greater than 1024 to port 21 of the server, and then opens port n + 1 for listening, and issue the port n + 1 command to the server. After receiving the command, the server uses its local FTP data port (usually 20) to connect to the specified port n + 1 of the client for data transmission.
In passive mode, the FTP client randomly opens a port n greater than 1024 to initiate a connection to port 21 of the server, and opens port n + 1. Then, send the PASV command to the server to notify the server that it is in passive mode. After receiving the command, the server opens a port P greater than 1024 for listening, and then uses the port p command to notify the client that its own data port is P. After receiving the command, the client connects to port P of the server through port n + 1 and transmits data between the two ports.
In general, active FTP refers to the data port on which the server actively connects to the client, and Passive FTP refers to the data port on which the server passively waits for the client to connect to itself.
In passive mode, FTP is usually used when FTP customers in the firewall access the external FTP server, because in this case, the firewall is usually configured to not allow external access to the host after the firewall, only connection requests initiated by hosts after the firewall are allowed to pass. Therefore, in this case, FTP transmission in active mode cannot be used, while FTP in passive mode can work well.