Timeout for CFC Method
I have a series of CFC methods which call each other (using cfinvoke) to determine the inventory of an item, and down in the lowest level of the calls, I'm making a Java Socket() call to my ERP server to get real-time inventory (and then that value is bubbled up and used through the calling CFCs to determine what message to display on our site. The issue I'm trying to deal with is how to gracefully recognize when there's no response from the ERP server and give up within 3 seconds. So ideally, I'd like to add some sort of timeout to either the method that makes the socket call itself, or the method that calls that method.
The socket class that I'm using has an internal connection timeout of 5 seconds, although it doesn't seem to really follow that. If I point it at a non-responsive address, it seems to take over a minute to give up and timeout. So I don't trust that setting, even if I wanted to recompile the class to receive the timeout as a parm. Here's the basic Java code used to create the socket connection:
Socket socket = new Socket();
try {
socket.connect(new InetSocketAddress(host, Integer.parseInt(port)), 1000);
socket.setSoTimeout(5000);
}
I tried adding <cfsetting requesttimeout="3"> to the method that makes the socket call based on some other posts I'd found, but it has no effect. I also tried making the final cfinvoke call as a webservice with the timeout parameter set, but again, it doesn't timeout.
Anybody have any other suggestions? Would love a CFTIMEOUT tag.
