Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at the jQuery Conference 2010 (Boston, MA) with:

ColdFusion CFFTP Timeout Value Cannot Be Dynamic

By Ben Nadel on
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).



Looking For A New Job?

100% of job board revenue is donated to Kiva. Loans that change livesFind out more »

Reader Comments

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

Reply to this Comment

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!

Reply to this Comment

@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?

Reply to this Comment

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.

Reply to this Comment

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...

Reply to this Comment

@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).

Reply to this Comment

@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)#">

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
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.