Note that there are some explanatory texts on larger screens.

plurals
  1. PODownloading an XML file via FTP
    primarykey
    data
    text
    <p>I have a list of feeds in a database that I use to download a XML file from a FTP server and then parse it. The scrpt is bundled up into a jar file which is run daily using Windows Task Scheduler. Occasionally the request get haulted at grabbing a certain xml file. So far it has happened about 3 times in 2 weeks with no real pattern that I can see. </p> <p>When it does mess up, I go to the computer it is being run from, I see the command window open and it is stopped before the xml has been fully downloaded. If I close the command window and run the task manually everything will work fine. </p> <p>The code that I am using to download the xml file is:</p> <pre><code>private void loadFTPFile(String host, String username, String password, String filename, String localFilename){ System.out.println(localFilename); FTPClient client = new FTPClient(); FileOutputStream fos = null; try { client.connect(host); client.login(username, password); String localFilenameOutput = createFile(assetsPath + localFilename); fos = new FileOutputStream(localFilenameOutput); client.retrieveFile(filename, fos); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) fos.close(); client.disconnect(); } catch (IOException e) { e.printStackTrace(); } } }</code></pre> <p>This function is being called in a loop and when it fails, everything stops and the script doesn't go onto the next feed.</p> <p>I'm not sure what is happening, possibly the connection being lost, but I would think that the try/catch would catch if that is happening. I'm not sure if a timeout would do the trick or threads need to be used (but I've never worked with threads)</p> <p>Could anyone point me in the right direction onto why this is happening and what I can do to fix the problem</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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