[ 
https://issues.apache.org/jira/browse/AXIS2-4330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12706730#action_12706730
 ] 

Amila Chinthaka Suriarachchi commented on AXIS2-4330:
-----------------------------------------------------

The reason for this problem is that by default Axis2 creates a new Http client 
(hence a connection manager) and this connection manager shuts down only when 
it time out.
So you need to create a connection manager *per thread* and close it before 
thread exists

public class MyThread extends Thread {
    private ServiceConnection serviceConnection = null;

    public void run() {
        serviceConnection = new ServiceConnection(address, pWord);
        while (true) {
            batchResultSet = getNewBatchData();
            while (batchResultSet.next()) {
                request = buildWebRequest(batchResultSet);
                // calling web service for each request
                response = serviceConnection.crCpu4(request);
                batchResultSet.close();
            }
        }

        // have to call this after while loop once it exists
        serviceConnection.shutDown();

    }

}

public class ServiceConnection {

    private TuxedoWebServiceStub tuxService;
    private TuxedoWebServiceStub.CRAN_CPU4WS inquiryReq = null;
    MultiThreadedHttpConnectionManager httpConnectionManager = null;

    public ServiceConnection(String url, String passwd) throws Exception {


        httpConnectionManager = new MultiThreadedHttpConnectionManager();
        HttpClient httpClient = new HttpClient(httpConnectionManager);

        tuxService = new TuxedoWebServiceStub(url);
        
tuxService._getServiceClient().getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
 Constants.VALUE_TRUE);
        
tuxService._getServiceClient().getOptions().setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
 httpClient);
        inquiryReq = new TuxedoWebServiceStub.CRAN_CPU4WS();
    }


    public String crCpu4(String request) {
        inquiryReq.setInbuf(request);
        TuxedoWebServiceStub.CRAN_CPU4WSResponse inquiryRep = 
tuxService.CRAN_CPU4WS(inquiryReq);
        if (inquiryRep != null)
            return inquiryRep.getOutbuf();
        return null;
    }

    public void shutDown(){
        httpConnectionManager.shutdown();
    } 

> axis2  client machine has many CLOSE_WAIT tcp
> ---------------------------------------------
>
>                 Key: AXIS2-4330
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4330
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: client-api
>    Affects Versions: 1.4.1
>         Environment: solaris
>            Reporter: jenny anderson
>         Attachments: TuxedoWebServiceStub.java
>
>
> My application is using axis2 web service. It  invokes web service thousand 
> times per second. We observed thousand CLOSE_WAIT connection after the 
> application is run for less than 10 hours.  I checked even I set 
> REUSE_HTTP_CLIENT to false, it still gets CLOSE_WAIT.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to