hi all,

 I noticed a set of issues related to http client issues[1]-[5]. Some of
these are resolved but as I saw there is no any confirmation from the people
who have reported the issue. So I think it is better to resolve these issues
for Axis2 1.5 if they still get these issues.


 Having some investigation I understood the number of connections made by
the client can be set to 1 by switching on the keep alive (with http 1.1)
with the following code.


 MultiThreadedHttpConnectionManager httpConnectionManager = new
MultiThreadedHttpConnectionManager();

HttpConnectionManagerParams params = new HttpConnectionManagerParams();

HostConfiguration hostConfiguration = new HostConfiguration();

hostConfiguration.setHost("localhost", 8085);

params.setMaxTotalConnections(10);

params.setMaxConnectionsPerHost(hostConfiguration, 2);

httpConnectionManager.setParams(params);


 HttpClient httpClient = new HttpClient(httpConnectionManager);


 while (true) {


 try {


 client = new ServiceClient(null, null);

Options opts = new Options();

client.setOptions(opts);

opts.setTo(new EndpointReference("
http://localhost:8085/axis2/services/TestInOutService";));

opts.setAction("urn:TestInOutService");


 OMElement payload = buildSoapObject(

"<ns1:getPrice xmlns:ns1=\"http://quickstart.samples/xsd\";>" +

"<ns1:symbol>IBM</ns1:symbol>" +

"</ns1:getPrice>"

);

System.out.println("Sending the request ..." + System.currentTimeMillis());


 client.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
Constants.VALUE_TRUE);

client.getOptions().setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
httpClient);

client.sendReceive(payload);



 } catch (Exception e) {

e.printStackTrace();

}

finally {

if (client != null) {

try {

client.cleanupTransport();

} catch (Exception e) {

e.printStackTrace();

}


 try {

client.cleanup();

} catch (Exception e) {

e.printStackTrace();

}

}


 }

try {

Thread.sleep(1000);

} catch (Exception e) {// do nothing}

}

}


 Here are the some of the observations I have made

Although http 1.1 by default use keep alive axis2 does not.

   The reason for this is axis2 by default creates a new httpClient and
   hence a Connection manager for each request. Http 1.1 keep alive works only
   when all the request uses same Connection manager and they use the same
   thread to invoke the execute method. We can satisfy the first requirement by
   reusing the http client object. The second requirement is automatically
   satisfied when using sendReceive() ( but this is not the case with
   sendReceiveNonBlocking() ) method unless client application starts new
   threads for different invocations.


 setting AUTO_RELEASE_CONNECTION is a wrong way to handle this scenario.

              this works with the out only operations but not synchronous
out in operations since it close the connection before reading the input
stream.

             the correct way is to use the serviceClient.cleanupTransport()
after the method invocations.

IMHO the first step in debugging this issue is to verify whether the client
uses one tcp connection or many using tcpmon. if it use only one tcp
connection then we need to figure out why the CLOSE_WAIT count goes up.


 Can some one reported this issue verify that whether they still getting
this with the above code.


 thanks,

Amila.


 [1] https://issues.apache.org/jira/browse/AXIS2-3670

[2] https://issues.apache.org/jira/browse/AXIS2-2883

[3] https://issues.apache.org/jira/browse/AXIS2-935

[4] https://issues.apache.org/jira/browse/AXIS2-2593

[5] https://issues.apache.org/jira/browse/AXIS2-2724

[6] https://issues.apache.org/jira/browse/AXIS2-2441


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Reply via email to