drazde 0 Posted July 15, 2019 (edited) Hi, I use TSslFtpClient component for connecting to a server via SSL (TSL connections), and also TSslContext and TSslAvlSessionCache. I can connect and trasfer some file, but after a while (7/8 seconds, and about 145 files) the session (not the connection) closes, so I close also the connection and restart it. I would know if is it possible avoid expire the session and do a reconnect to the server. I have to transfer also thousands of file at a time Thanks in advance PS: if I try to copy many file with the OverbyteIcsXferTst1 example, that use TIcsFtpMulti, It give me "FTP Session Closed - Connection reset by peer (#10054)" after only having transferred 45 files Edited July 15, 2019 by drazde Share this post Link to post
Angus Robertson 574 Posted July 15, 2019 Problems like that are hard to track down, could be client or server, perhaps something to do with SSL session caching since each new file opens a new SSL connection. Trying to debug is almost impossible due to the volume of data created after 145 files. You can try other clients to the server, or your client to a different server, you can test against the ICS FTP server on one of my pubic servers. I download hundreds of log files daily from those servers using FTP and errors are very rare. But I use the new (to ICS) TIcsFtpMulti component and that does automatic retries if a file download or upload fails. Angus Share this post Link to post
drazde 0 Posted July 15, 2019 With TIcsFtpMulti , I have problem after only 45 files, this is the log (the last lines) of the sample project. 15:51:51:465 Upload OK: C:\CBA\Cartella Socio Sanitaria\ServizioAS\TestCopiaFTP\CopiaInFtp\ArchiviazioneSostitutiva\ARSENIO LUPIN-3454\MUST.pdf, size: 254 Kbytes, duration 0, average speed 0/sec 15:51:51:466 > MFMT 20190715092158 must.pdf 15:51:51:467 < 213 Modify=20190715092158; must.pdf 15:51:51:467 Check Exists C:\CBA\Cartella Socio Sanitaria\ServizioAS\TestCopiaFTP\CopiaInFtp\ArchiviazioneSostitutiva\ARSENIO LUPIN-3454\MUST.xml 15:51:51:467 Uploading File 63 of 839, C:\CBA\Cartella Socio Sanitaria\ServizioAS\TestCopiaFTP\CopiaInFtp\ArchiviazioneSostitutiva\ARSENIO LUPIN-3454\MUST.xml to /archiviazionesostitutiva/arsenio lupin-3454/must.xml, size 1,38 Kbytes 15:51:51:467 > MLST MUST_xml 15:51:51:469 < 550 'MUST_xml' non può essere interrogato 15:51:51:469 MLST Failed with Status 550 - 550 'MUST_xml' non può essere interrogato 15:51:51:469 > MDTM MUST_xml 15:51:51:470 < 550 MUST_xml: File o directory non esistente 15:51:51:470 MDTM Failed with Status 550 - 550 MUST_xml: File o directory non esistente 15:51:51:672 > PASV 15:51:51:673 < 227 Entering Passive Mode (192,168,10,198,147,175). 15:51:51:673 > LIST MUST_xml 15:51:51:675 Check for Old SSL Session 15:51:51:676 Old SSL Session Found Cached 15:51:51:676 < 150 Apertura della connessione dati in modalità BINARY per file list 15:51:51:681 ! SSL Connected OK with TLSv1.2, cipher ECDHE-RSA-AES128-GCM-SHA256, key auth RSA, key exchange ECDH, encryption AESGCM(128), message auth AEAD 15:51:51:682 SSL Connected OK with TLSv1.2, cipher ECDHE-RSA-AES128-GCM-SHA256, key auth RSA, key exchange ECDH, encryption AESGCM(128), message auth AEAD 15:51:51:686 < 450 MUST_xml: File o directory non esistente 15:51:51:686 ! RETR/LIST/NLST Failed 15:51:51:686 DIR Failed with Status 450 - 450 MUST_xml: File o directory non esistente 15:51:51:686 Unable to Resume, Partial File Not Found: MUST_xml 15:51:51:876 > ALLO 1410 15:51:51:878 < 202 Nessuna allocazione di spazio su disco necessaria 15:51:51:882 Saved File Resume Info C:\CBA\Cartella Socio Sanitaria\ServizioAS\TestCopiaFTP\CopiaInFtp\ArchiviazioneSostitutiva\ARSENIO LUPIN-3454\MUST.xml.ftp 15:51:51:882 > PASV 15:51:51:884 FTP Session Closed - Connection reset by peer (#10054) 15:51:51:884 Lost FTP Control Connection, Abandoning Uploads 15:51:51:884 No Connection to Server, Cancelled Uploading Files (3) 15:51:51:884 Task Result: Failed 15:51:51:884 No Connection to Server, Cancelled Uploading Files (3) I also tried with FileZilla and also give some error... (I cut the line not interesting) Errore: Disconnesso dal server: ECONNABORTED - Connessione interrotta Errore: Trasferimento fallito Errore: Disconnesso dal server: ECONNABORTED - Connessione interrotta Errore: Trasferimento fallito Errore: Disconnesso dal server: ECONNABORTED - Connessione interrotta Errore: Trasferimento fallito Errore: Disconnesso dal server: ECONNABORTED - Connessione interrotta Errore: Trasferimento fallito Share this post Link to post
drazde 0 Posted July 15, 2019 I use this pice of code for manage the SSL Session, and I use the latest release of ICS 8.61 procedure TForm1.FTPSslCliGetSession(Sender: TObject; var SslSession: Pointer; var FreeSession: Boolean); begin SslSession := SslAvlSessionCache1.GetCliSession(FTP.HostName + FTP.Port, FreeSession); end; procedure TForm1.FTPSslCliNewSession(Sender: TObject; SslSession: Pointer; WasReused: Boolean; var IncRefCount: Boolean); begin if (not WasReused) then begin SslAvlSessionCache1.CacheCliSession(SslSession, FTP.HostName + FTP.Port, IncRefCount); end end; Share this post Link to post
Angus Robertson 574 Posted July 15, 2019 Sorry, no simple answer, the issue might also relate to NAT translation in a router somewhere, which has to keep track of all the sessions. I had a Netgear router in the early days of broadband that could not handle more than one file per session. While TIcsFtpMulti retries individual files on error, once the control connection dies nothing works, but my higher level application then retries the whole job. This happens with non-SSL as well. As I said, never got the bottom of it, just have to cope with the errors. Angus Share this post Link to post
drazde 0 Posted July 16, 2019 Ok, thank you so much for help me, I'm not expert with SSL and FTP, so I don't know if I do all the right operations. Sometimes happen that the session will close after a while, sometimes happen connection close when try to do some command (example: "Failed to change dir: 500 Control connection closed - Winsock - Connection reset by peer (#10054)". I will try to test the copy with other client Share this post Link to post
drazde 0 Posted July 16, 2019 [UPDATE] I found this post: https://www.experts-exchange.com/questions/29124840/Socket-error-10054-during-ftp-session.html So I try to disable the Windows Firewall and my problem are solved! Now I have to find a correct rule to add at Windows Firewall... Share this post Link to post
Angus Robertson 574 Posted July 16, 2019 I don't run Windows Firewall anywhere, and still see rare problems, thus the retries. Adding your EXE to the exception list may help, but not be a complete solution. Angus Share this post Link to post
drazde 0 Posted July 17, 2019 (edited) On 7/16/2019 at 12:22 PM, Angus Robertson said: I don't run Windows Firewall anywhere, and still see rare problems, thus the retries. Adding your EXE to the exception list may help, but not be a complete solution. Angus Ok, the components works well, it is a problem of Windows Firewall, I resolved managing the unwanted session closed and reopening the connection (like FileZilla does) Edited July 17, 2019 by drazde Share this post Link to post
nouvakis 0 Posted November 6, 2019 (edited) On 7/17/2019 at 4:11 PM, drazde said: Ok, the components works well, it is a problem of Windows Firewall, I resolved managing the unwanted session closed and reopening the connection (like FileZilla does) can you describe what do you mean "resolved managing unwanted session" ? Edited November 6, 2019 by nouvakis Share this post Link to post