List of usage examples for org.apache.commons.net.ftp FTPSClient setControlKeepAliveTimeout
public void setControlKeepAliveTimeout(long controlIdle)
From source file:ddf.test.itests.catalog.TestFtp.java
private FTPSClient createSecureClient(boolean setKeystore) throws Exception { FTPSClient ftps = new FTPSClient(); if (setKeystore) { KeyManager keyManager = KeyManagerUtils.createClientKeyManager( new File(System.getProperty("javax.net.ssl.keyStore")), System.getProperty("javax.net.ssl.keyStorePassword")); ftps.setKeyManager(keyManager);//from w w w .j av a 2s . co m } int attempts = 0; while (true) { try { ftps.connect(FTP_SERVER, Integer.parseInt(FTP_PORT.getPort())); break; } catch (SocketException e) { // a socket exception can be thrown if the ftp server is still in the process of coming up // or down Thread.sleep(1000); if (attempts++ > 30) { throw e; } } } showServerReply(ftps); int connectionReply = ftps.getReplyCode(); if (!FTPReply.isPositiveCompletion(connectionReply)) { fail("FTP server refused connection: " + connectionReply); } boolean success = ftps.login(USERNAME, PASSWORD); showServerReply(ftps); if (!success) { fail("Could not log in to the FTP server."); } ftps.enterLocalPassiveMode(); ftps.setControlKeepAliveTimeout(300); ftps.setFileType(FTP.BINARY_FILE_TYPE); return ftps; }