CFFTP Transfers a Zero-Byte File and Throws a Timeout Error

Although I’ve used ColdFusion for 7+ years now, I’ve never used the cfftp tag before. Yesterday, I found a reason to try it out. I figured it would be as simple as cfhttp–and it was, with one exception (no pun intended).

Here is my sample code:

<cfftp action="open" 
    connection="test"
    server="ftp.osric.com"
    username="chris"
    password="********************"
    timeout="60"
    stoponerror="yes">
<cfftp  
    connection = "test" 
    action = "getFile"  
    name = "downloadFile"  
    transferMode = "binary"  
    localFile = "S:\chris\handlebar-moustache.jpg"  
    remoteFile = "handlebar-moustache.jpg"
    timeout="60">

Here’s the error message it produced:
An error occurred during the FTP getFile operation.
Error: getFile operation exceeded timeout.

However, the local file was still created (as a zero-byte file).

The solution, in my case, was to turn on passive mode (add attribute passive="yes" to the cfftp tag).

Active FTP vs. Passive FTP, a Definitive Explanation has a brief explanation of the differences between active and passive FTP.

3 thoughts on “CFFTP Transfers a Zero-Byte File and Throws a Timeout Error”

  1. This worked in a situation where we upgraded to CF10 and the CFFTP function kept timing out. Thank you!!

Leave a Reply

Your email address will not be published.