To get more information on the connection, I looked to Filezilla's debugging tools. Under [Settings], [Debug] I bumped the logging level to [2 - Info]
In the connection scroll, I saw something interesting. The ciphers were ordinary: SHA1 and Blowfish-128, but zlib stood out. Zlib compresses data at the transmission level, similar to gzip but patently different. ColdFusion doesn't handle gzip natively (though there are clever workarounds), so I suspected that CFFTP was having a problem with zlib.
I searched the internet for Java libraries that could sFTP with zlib enabled and the overwhelming majority of links pointed me to JCraft JSch. To my surprise, I discovered that ColdFusion 9 implements a modified version of JSch 1.41 library (C:\ColdFusion9\lib\jsch-0.1.41m.jar). The zlib functionality is not part of the core JSch, but is part of jzlib.jar (also available free from JCraft). I added jzlib.jar to the classpath and it worked like a charm. Here is my proof of concept code:
<cfscript> FTPSERVER = "someserver.somewhere.com"; FTPPORT = "22"; FTPUSER = "someuser"; FTPPW = "somepassword"; jschObj = createobject('java',"com.jcraft.jsch.JSch"); jschSession = jschObj.getSession(FTPUSER, FTPSERVER); jschConfig = createObject("java","java.util.Properties"); jschConfig.put("StrictHostKeyChecking","no"); jschConfig.put("compression.s2c", "zlib,none"); //server to client jschConfig.put("compression.c2s", "zlib,none"); //client to server jschSession.setConfig(jschConfig); jschSession.setPort(FTPPORT); jschSession.setPassword(FTPPW); jschSession.connect(); jschChannel = jschSession.openChannel("sftp"); jschChannel.connect(); if (jschSession.isConnected()) { WriteOutput("CONNECTED!"); } jschChannel.cd("/Test"); FileInputStream = createobject("java", "java.io.FileInputStream").init(expandPath("payload_test.txt")); jschChannel.put(FileInputStream, "payload_test.txt"); WriteDump(jschChannel); jschChannel.disconnect(); jschSession.disconnect(); </cfscript>The two commented lines enable zlib for upstream and downstream transmissions. This resolved our connection issues.
Is there any way to handle situation like , If a file transfer fails half way through then continue the file transfer from where it left off using this java library.
ReplyDeleteI'm afraid I don't know. In the time since this post, I have moved on to C#/.NET. The good news is that this is a popular library in the java world. You might post this question on Stack Overflow and tag with [ColdFusion] and [Java].
Delete