Timeout when Uploading Large File from Client to Server

If you can transfer small files without any issues, but transfers of larger files end with a timeout, a broken router and/or firewall may exist between the client and the server and is causing a problem.

FTP uses two TCP connections: a control connection to submit commands and receive replies, and a data connection for actual file transfers. It is the nature of FTP that during a transfer the control connection stays completely idle.

The TCP specifications do not set a limit on the amount of time a connection can stay idle. Unless explicitly closed, a connection is supposed to remain alive indefinitely. However, many routers and firewalls automatically close idle connections after a certain period of time. For FTP, this means that during a long transfer the control connection can get dropped because it is detected as idle, but neither client nor server are notified. So when all data has been transferred, the server assumes the control connection is alive and it sends the transfer confirmation reply. Likewise, the client thinks the control connection is alive and it waits for the reply from the server. But since the control connection got dropped without notification, the reply never arrives and eventually the connection will timeout.

In an attempt to solve this problem, the TCP specifications include a way to send keep-alive packets on otherwise idle TCP connections, to tell all involved parties that the connection is still alive and needed. However these keep-alive packets should not be sent more often than once every two hours. Therefore, with added tolerance for network latency, connections can stay idle for up to 2 hours and 4 minutes.

However, many routers and firewalls drop connections that have been idle for less than 2 hours and 4 minutes. In other words, all routers and firewalls that are dropping idle connections too early cannot be used for long FTP transfers. To solve this problem, you need to uninstall affected firewalls and replace the faulty routers.

Tags: , , ,