ColdFusion CFFTP Timeout Value Cannot Be Dynamic

Posted August 29, 2008 at 10:05 AM by Ben Nadel

Tags: ColdFusion

Yesterday, when I was messing around with my first ColdFusion 8 sFTP commands using CFFTP, I came across a strange timeout bug. Many tags in ColdFusion allows us to enter override Timeout values. These values are always entered as seconds:

Timeout="30"

To make the code more readable, I like to make the timeout value dynamic when it has to be large. So, rather than doing:

Timeout="300"

... I'll make it more obvious:

Timeout="#(60 * 5)#"

While this might seem silly, 60*5 actually gives the programmer much more information than the value 300. For starters, by seeing the value "60" first, it indicates that the Timeout value is in seconds (rather than milliseconds). Secondly, by seeing 60*5, no calculation is required to know that the Timeout is set to 5 minutes; no having to divide 300 by 60 to see how many minutes that works out to.

Clearly, it's a great way to define Timeout values, but that's not what we're here to discuss. When I started to code my CFFTP example, I employed the same Timeout style setting:

  • <!---
  • Open the connection, cache it using, "objConnection",
  • and give it a large timeout.
  • --->
  • <cfftp
  • action="open"
  • connection="objConnection"
  • timeout="#(60 * 5)#"
  • attributeCollection="#objFTPProperties#"
  • />
  •  
  • <!--- Close the connection. --->
  • <cfftp
  • action="close"
  • connection="objConnection"
  • />

Here, as in my explanation above, I am setting the Timeout dynamically to be 5 minutes. Unfortunately, when I run the code, ColdFusion throws the following error:

(class: cftest2ecfm2015631588, method: runPage signature: ()Ljava/lang/Object;) Expecting to find object/array on stack null. The error occurred on line -1. java.lang.VerifyError: (class: cftest2ecfm2015631588, method: runPage signature: ()Ljava/lang/Object;) Expecting to find object/array on stack.

Well, obviously, right :) Talk about a ColdFusion error that give you zero insight into what actually went wrong.

Anyway, when I took out the dynamic Timeout value and put in a static "300," the page worked fine. Clearly a bug (that I have reported).




Reader Comments

Aug 29, 2008 at 12:10 PM // reply »
8 Comments

What happens if you assign 60 * 5 to a variable, and then plug the variable into the attribute?


Aug 29, 2008 at 3:19 PM // reply »
132 Comments

That seems to be CF generating an inconsistent class file. Something in the compiler is doing something naughty.

You should report this to Adobe, Definitely a bug!


Aug 29, 2008 at 3:20 PM // reply »
132 Comments

I'm slow... I see that you have reported it. Woops. My bad.


Aug 29, 2008 at 3:26 PM // reply »
10,640 Comments

@Duncan,

I did not try to do it as a variable. I just resorted to putting in the full time rather than the calculation.

@Elliott,

Naughtiness reported :) Weird looking error, right?


Aug 30, 2008 at 12:46 AM // reply »
14 Comments

Interesting finding! I wonder if it's just the calculation it has to do for the timeout value or if it's any variable at all.


Jan 12, 2010 at 5:38 AM // reply »
7 Comments

A little late, but this worked for other tags that gave the dynamic error...

I haven't tried it the cfftp timeout yet, but I think #int(60 * 5)# should work just fine...


Jan 13, 2010 at 8:19 PM // reply »
10,640 Comments

@Michael,

If you test it, let us know if it works (I don't have any FTP stuff set up for testing at the moment).


Jan 14, 2010 at 10:13 AM // reply »
7 Comments

@Ben Nadel,

Yessss Works like a charm!

<cfftp action = "open"

username = "Foo"

connection = "connection1"

password = "nonono"

server = "ftp.somethi.ng"

stopOnError = "Yes" timeout="#int(60 * 5)#">


Jan 16, 2010 at 5:21 PM // reply »
10,640 Comments

@Michael,

Very odd! I wonder why that works. Good to know - thanks for running the test.


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Feb 12, 2012 at 3:37 AM
Learning ColdFusion 8: CFImage Part III - Watermarks And Transparency
Hi Ben, Just to ask currently it is placed bottom right corner, if i need to replace the same rendered image on the bottom left side or in the bottom center, how that can be calculated. bottom ce ... read »
Feb 11, 2012 at 9:29 PM
Use jQuery's SlideDown() With Fixed-Width Elements To Prevent Jumping
I can't say how glad I am that I found your post. Thank you very much. ... read »
Feb 10, 2012 at 7:21 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
Update! Instead of $(eval(options.insertAfter)).after(data['insertData']); I now use: var ajaxNode = document.createElement('span'); var parent = $(eval(options.insertAfter))[0].parentNode; ... read »
Feb 10, 2012 at 6:18 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
encountered this same, what I consider, jQuery bug last week. I'm building a site in which I load some content via AJAX. This content contains Linkedin share button placeholders which Linkedin API ne ... read »
Feb 10, 2012 at 11:30 AM
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
After you understand the concepts here, this is an awesome cheatsheet for enabling CORS in just about anything http://enable-cors.org/ ... read »
JM
Feb 10, 2012 at 9:10 AM
My Safari Browser SQLite Database Hello World Example
@Amy, Here is a very good tutorial on how to use JOIN: http://www.sqltutorial.org/sqljoin-innerjoin.aspx ... read »
Feb 10, 2012 at 4:42 AM
Building A Twitter-Inspired RESTful API Architecture In ColdFusion
This is great, very useful Ben. I spotted a small typo in the api.cgm listing: <cfthrow type="Unauthroized" /> Cheers Stefan ... read »
Feb 9, 2012 at 10:35 PM
CFDirectory Filtering Uses Pipe Character For Multiple Filters (Thanks Steve Withington)
I was wondering if there would be a filter you could apply so that you got everything but what you included in the filter. As in show me all docs that are not a .pdf. ... read »