KB-20071207-030

From Triled Wiki

Jump to: navigation, search


The receive() call always blocks for long period if there is no data available.

code example (from f c post):

private static final int DEF_CONN_TIMEOUT_MS = 1;
private static final int DEF_SO_TIMEOUT_MS = 1;
private static final int RETRIES=1;

HttpClient client = new HttpClient();
HttpConnectionManagerParams params=
client.getHttpConnectionManager().getParams();
params.setSoTimeout(DEF_SO_TIMEOUT_MS);
params.setConnectionTimeout(DEF_CONN_TIMEOUT_MS);

GetMethod method = new GetMethod(url);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                        new DefaultHttpMethodRetryHandler(RETRIES, false));

client.executeMethod(method);
String s = method.getResponseBodyAsString(); 

Expected behaviour - immediate return (1 ms timeout) if server is not available. But socket timeout in fact is not set by setSoTimeout() and application stays in wait state.

Personal tools