Question

I'm trying to call a method on a static Java class which could take anywhere from 10 seconds to a minute to run. After about 30 seconds, I get the Exception

java.net.SocketTimeoutException: Read timed out; Is the timeout preference too low? Are you dumping/calling debug() on large data or cfc instances?

I have been able to replicate it with the following minimal example. In Java:

package some.package;
public class Sleeper {
    public static void sleep(int seconds) {
        Thread.sleep(seconds * 1000);
    }
}

And then I have an MxUnit test:

<cffunction name="timeoutTest" access="public" returnType="void" output="false>
    <cfset sleeper = CreateObject("java", "some.package.Sleeper" />
    <cfset runner.sleep(32) />
</cffunction>

Setting my Timeout Requests after ( seconds) to 99999 on the server settings did not help, nor did changing the test to:

<cffunction name="timeoutTest" access="public" returnType="void" output="false>
    <cfset sleeper = CreateObject("java", "some.package.Sleeper" />
    <cfsetting requesttimeout="64" />
    <cfset runner.sleep(32) />
</cffunction>

I imagine there is a setting somewhere, but if so I cannot find it. I am running ColdFusion 8

Was it helpful?

Solution

ColdFusion was not the problem, MxUnit was. By default, unit tests timeout after 30 seconds. This can be changed in Eclipse by going to Window -> Preferences -> MXUnit and changing the "Method Timeout" field to 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top