Axis2 client: Where is timeout defined for java.net.SocketTimeoutException

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Axis2 client: Where is timeout defined for java.net.SocketTimeoutException

Hitesh Sajnani
Hello all,

We are using axis2 1.5.4 lib which has default timeout 30 seconds in axis2.xml:

<parameter name="ConfigContextTimeoutInterval">30000</parameter>


I'm setting the timeout to 15 seconds as follows in my code: (using apache common-httpclient-3.1):

ConfigurationContext configurationContext = serviceClient.getServiceContext().getConfigurationContext();
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setConnectionTimeout(15000);
params.setSoTimeout(15000);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);


Testing locally on my desktop, it times out correctly at 15 seconds. Whereas on other machine (production servers), it times out at 30 seconds.

What is the config that is governing this behaviour of timeout?

We are getting following timeout exceptions:

DEBUG - org.apache.axis2.AxisFault: Read timed out
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) ~[axis2-kernel-1.5.4.jar:1.5.4]
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203) ~[axis2-transport-http-1.5.4.jar:?]
    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76) ~[axis2-transport-http-1.5.4.jar:?]
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400) ~[axis2-transport-http-1.5.4.jar:?]
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225) ~[axis2-transport-http-1.5.4.jar:?]
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438) ~[axis2-kernel-1.5.4.jar:1.5.4]
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402) ~[axis2-kernel-1.5.4.jar:1.5.4]
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) ~[axis2-kernel-1.5.4.jar:1.5.4]
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) ~[axis2-kernel-1.5.4.jar:1.5.4]
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:540) ~[axis2-kernel-1.5.4.jar:1.5.4]
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:521) ~[axis2-kernel-1.5.4.jar:1.5.4]
    :
    :
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method) ~[?:1.7.0_17]
    at java.net.SocketInputStream.read(Unknown Source) ~[?:1.7.0_17]
    at java.net.SocketInputStream.read(Unknown Source) ~[?:1.7.0_17]
    at java.io.BufferedInputStream.fill(Unknown Source) ~[?:1.7.0_17]
    at java.io.BufferedInputStream.read(Unknown Source) ~[?:1.7.0_17]
    at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) ~[commons-httpclient-3.1.jar:?]
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) ~[commons-httpclient-3.1.jar:?]
    at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557) ~[axis2-transport-http-1.5.4.jar:?]
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199) ~[axis2-transport-http-1.5.4.jar:?]
    ... 16 more


I'm confused which timeout works!? It would be great if someone can help understand the behaviour.

Thank you