I am using Coldfusion 9. I have verified that the sFTP host is valid and I can connect using "CyberDuck". The port is not the standard 21 (ftp) or 22 (ssh)
<cfftp
username= "myysername"
password= "mypassword"
port= "6589"
server= "ftphost.com"
secure= "yes"
name= "ftpconnection"
action= "open" />
<cfdump var="#ftpconnection#">
The result, after about 1 minute is :
com.jcraft.jsch.JSchException: Session.connect: java.net.SocketTimeoutException: Read timed out
at com.jcraft.jsch.Session.connect(Unknown Source)
at com.jcraft.jsch.Session.connect(Unknown Source)
at coldfusion.tagext.net.SftpHandler.getConnection(SftpHandler.java:265)
at coldfusion.tagext.net.SftpHandler.createConnection(SftpHandler.java:76)
at coldfusion.tagext.net.FtpTag.doStartTag(FtpTag.java:675)
at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)
I have also tried building this connection by calling the JSCH classes ( http://www.jcraft.com/jsch/examples/Sftp.java.html ) manually, but to no avail.
The question is, why is this timing out in code, but not when using a program like CyberDuck ?
EDIT TO ADD CF-Java code
jsch = CreateObject("java", "com.jcraft.jsch.JSch");
jsession = CreateObject("java", "com.jcraft.jsch.Session");
jChannel = CreateObject("java", "com.jcraft.jsch.Channel");
jChannelSFTP = CreateObject("java", "com.jcraft.jsch.ChannelSftp");
jUserInfo = CreateObject("java", "com.jcraft.jsch.UserInfo");
jProperties = CreateObject("java", "java.util.Properties");
jLogger = CreateObject("java", "com.jcraft.jsch.Logger");
host = "ftphost.com";
username = "myusername";
portNumber = "6589";
javaCast("String", "host");
javaCast("String", "username");
/* *********************** */
jProperties.put("StrictHostKeyChecking", "no");
jsession = jsch.getSession(username, host, portNumber);
jsession.setPassword("mypassword");
jsession.setPort(6589);
jsession.setUserInfo(jUserInfo);
jsession.setConfig(jProperties);
writeOutput("Connect ...");
getPageContext().getOut().flush();
jsession.connect();
writeOutput("done <br>");
This code doesn't error per se, but the connect() method never "returns" :
connection is closed by foreign host
The error occurred in /Library/WebServer/Coldfusion/SFTP/index.cfm: line 53
51 : writeOutput("Connect ...");
52 : getPageContext().getOut().flush();
53 : jsession.connect();
54 : writeOutput("done <br>");
55 :
EDITED TO SHOW CYBERDUCK CONNECTION LOG
220 Service ready for new user.
AUTH TLS
234 Command AUTH okay; starting TLS connection.
USER myusername
331 User name okay, need password for myusername.
PASS ********
230 User logged in, proceed.
PBSZ 0
200 Command PBSZ okay.
PROT P
200 Command PROT okay.
FEAT
[ ... ]
OPTS UTF8 ON
200 Command OPTS okay.
NOOP
200 Command NOOP okay.
SYST
215 UNIX Type: Apache FtpServer
STAT /root
200--rw------- 1 SMG TGMS 263375 Nov 25 01:35 afile.txt