I want to run thread safe, asynchronous HTTP requests using HTTPClient. I noticed that it does not respect my CONNECTION_TIMEOUT
argument.
The code is ColdFusion / Java hybrid.
client = loader.create("org.apache.http.impl.nio.client.DefaultHttpAsyncClient").init();
CoreConnectionPNames = loader.create("org.apache.http.params.CoreConnectionPNames");
client.getParams()
.setIntParameter(JavaCast("string", CoreConnectionPNames.SO_TIMEOUT), 10)
.setIntParameter(JavaCast("string", CoreConnectionPNames.CONNECTION_TIMEOUT), 10);
client.start();
request = loader.create("org.apache.http.client.methods.HttpGet").init("http://www.google.com");
future = client.execute(request, javacast("null", ""));
try {
response = future.get();
}
catch(e any) {}
client.getConnectionManager().shutdown();
Regardless of what I supply for CONNECTION_TIMEOUT, the requests always return 200 OK. Check the output below.
- How do I set an effective connection timeout?
- Does CONNECTION_TIMEOUT do anything?
Output
200 OK http://www.google.com/
200 OK http://www.google.com/
[snip]
5 requests using Async Client in: 2308 ms