Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
jmceachern
Contributor
Contributor

close a TFTPConnection

I have a DI job with the following flow:
tFTPConnection -> tFTPFileList -> tFTPGET -> tJava -> tFTPRename
I check the "Use an existing connection" checkbox for the subsequent tFTP components.
Everything works fine but, once we scheduled this job, it caused issues with the SFTP server we are connecting to since the connections were never closed. We wound up with multiple attempted connections.
I searched on this issue and found some forum posts from a few years ago. But I'm wondering if there's updated information on this topic. What's the best way for me to close the SFTP connection at the end of the job?
Labels (3)
2 Replies
Anonymous
Not applicable

Actually this would be a good reason to build a component!
Add a tJava component to your job where you want to close the connection and add this code:
You have to apply your tFTPConnection number for the global map key.
This code works only for the SFTP connection.
com.jcraft.jsch.ChannelSftp c_tFTPConnection_1 = (com.jcraft.jsch.ChannelSftp) globalMap.get("conn_tFTPConnection_1");
c_tFTPConnection_1.disconnect();

In case of simple FTP use this code:
com.enterprisedt.net.ftp.FTPClient ftp_tFTPConnection_1 = (com.enterprisedt.net.ftp.FTPClient) globalMap.get("conn_tFTPConnection_1");
ftp_tFTPConnection_1.executeCommand("exit");
Anonymous
Not applicable