Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>UPDATE - Set a timeout for the data connection</h1> <p>Since the last file is only partially downloaded, and given the source of <a href="http://commons.apache.org/net/api-3.1/src-html/org/apache/commons/net/ftp/FTPClient.html#line.1666" rel="nofollow noreferrer"><code>FTPClient.retrieveFile()</code></a>, I think it may be a problem on the server side (something that make it hang, or even die - <em>who knows</em>). Obviously one can't repair the server or even know what's going on there, anyway I suggest to add a timeout with <a href="http://commons.apache.org/net/api-3.1/org/apache/commons/net/ftp/FTPClient.html#setDataTimeout%28int%29" rel="nofollow noreferrer"><code>setDataTimeout(int)</code></a> and catch the possible <code>SocketTimeoutException</code> separately to be logged in a different place and maybe sent to the FTP server admins (along with the time information when it happened) so they can merge the logs and see what's the issue.</p> <p><strong>OLD ANSWER</strong></p> <p>I didn't notice that you connect and login for each and every file, so the following is just an <em>optimization</em> not to close the control connection and succesfully logout, but it should <strong>not</strong> address the problem.</p> <p>You could start the JVM in debug mode and attach a debugger when it hangs, anyway according to <a href="https://stackoverflow.com/a/10530366/315306">this answer</a> and <a href="http://apache-commons.680414.n4.nabble.com/FTPClient-hangs-when-downloading-large-files-td3307715.html" rel="nofollow noreferrer">this thread</a> it can be a timeout problem on the network equipment devices (routers). From the <a href="http://commons.apache.org/net/api-3.1/org/apache/commons/net/ftp/FTPClient.html" rel="nofollow noreferrer">FTPClient Javadoc</a></p> <blockquote> <p>During file transfers, the data connection is busy, but the control connection is idle. FTP servers know that the control connection is in use, so won't close it through lack of activity, but it's a lot harder for network routers to know that the control and data connections are associated with each other. Some routers may treat the control connection as idle, and disconnect it if the transfer over the data connection takes longer than the allowable idle time for the router.</p> </blockquote> <p>One solution to this is to send a safe command (i.e. NOOP) over the control connection to reset the router's idle timer. This is enabled as follows:</p> <pre><code>ftpClient.setControlKeepAliveTimeout(300); // set timeout to 5 minutes </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload