I'm implementing FTP behavior based on the above site. In the above site, I've only added passive mode to the ftp settings.
@Bean
public DefaultFtpSessionFactory sf() {
DefaultFtpSessionFactory sf = new DefaultFtpSessionFactory();
sf.setHost(host);
sf.setPort(port);
sf.setUsername(username);
sf.setPassword(password);
sf.setClientMode(FTPClient.PASSIVE_LOCAL_DATA_CONNECTION_MODE);
return sf;
}
And I want to check the passive port when communicating in practice.
@ServiceActivator(inputChannel = "ftpMGET")
@Bean
public FtpOutboundGateway getFiles() {
DefaultFtpSessionFactory ftpSessionFactory = sf();
FtpOutboundGateway gateway = new FtpOutboundGateway(ftpSessionFactory, "mget", "payload");
gateway.setAutoCreateDirectory(true);
gateway.setLocalDirectory(new File(downloadPath));
gateway.setFileExistsMode(FileExistsMode.APPEND);
gateway.setFilter(new AcceptOnceFileListFilter<>());
gateway.setOutputChannelName("fileResults");
gateway.setOption(AbstractRemoteFileOutboundGateway.Option.RECURSIVE);
System.out.println(ftpSessionFactory.getSession().getClientInstance().getPassivePort());
return gateway;
}
At the end, I added a passivePort with System.out.println.
It keeps saying -1, but how do I check the passive port when downloading a file from a real server?!