Ftp.ReceiveTimeout
and Ftp.SendTimeout
are set to 20 seconds by default. You may modify them:
client.ReceiveTimeout = TimeSpan.FromMinutes(1);
If 'No data received' error happens during large file transfers, it might indicate that control connection is closed due to inactivity.
Setting keep alive can be useful to prevent routers from prematurely closing the control channel while a long data transfer is taking place.
You may use KeepAliveDuringTransfer(TimeSpan noopInterval)
method,
before starting the transfer, to send NOOP commands on the control channel at specified intervals:
client.KeepAliveDuringTransfer(TimeSpan.FromMinutes(1));
Please note that some FTP servers don't support receiving NOOP commands during file transfers.
It's been observed that these servers will act strangely: not reply to the command, or only send the reply after the file transfer has completed. This will cause the component to throw a timeout exception since it's expecting a reply within the timeout period.
You can also try KeepAliveTcp(TimeSpan keepAliveTime, TimeSpan keepAliveInterval)
for example:
client.KeepAliveTcp(
TimeSpan.FromMinutes(10),
TimeSpan.FromSeconds(1));
It causes the control socket to use TCP KeepAlive.
First parameter specifies the time after first KeepAlive is send.
Second parameter specifies the interval for subsequent KeepAlives.
Default TCP protocol values are 2 hours and 1 second.
You should also examine the logs:
https://www.limilabs.com/blog/logging-in-ftp-dll