• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem retrieving a zip file from FTP server using FTPClient commons-net-1.3.0.jar

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am trying to retrieve several zip files from FTP site using FTPClient . The retrieve process hangs when trying to get large files of 5MB.
the thread hangs without any errors or exceptions, although IO exceptions are handled in the code.
this has been happening repeatedly, since a week. Only on the application restart the process again starts adn then after sometime it again hangs.
There is no issue in retrieving smailler zip files.

Please help. Proghram attached below.


private boolean retrieveFromFTPSite(String ftpUrl,String username,String password,FTPClient ftp, String filePath) {


try {
TimeOutSetFactory timeOutSetFactory = new TimeOutSetFactory();
//Setting timeout to 20 seconds in TimeOutFactory class.
timeOutSetFactory.setTimeOut(20*1000);
ftp.setSocketFactory(timeOutSetFactory);
ftp.connect(ftpUrl);
ftp.login(username, password);
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024 * 1024 * 2);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
System.out.println( "Timeout period"+ftp.getSoTimeout());
ftp.retrieveFile(filePath, bos); // thread hangs here
if (bos.toByteArray().length < 10) {
throw new IOException("Empty or corrupted file " + filePath);
}
bos.close();
return true;
} catch (IOException ioe) {

System.out.println("Error retrieving file. " + ioe.getMessage());
return false;
}
finally{
try {
ftp.logout();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use code tags.
 
priyanka pal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you really not indent your code?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic