axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amila Chinthaka Suriarachchi (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AXIS2-2883) CLOSE_WAIT slowly building up over the period of time.
Date Sun, 03 May 2009 02:06:30 GMT

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

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

Has some one tried with a client as given below to get this work with http 1.1?

With http 1.1 it is possible to use keep alive to enhance the performance and reduce the
number of connections made to the server. i.e when you use keep alive feature client only
create one connection with the server. So there is no possibility to get multiple CLOSE_WAIT
state connections.

By default axis2 creates a httpClient for each and every request. Hence it creates different
MultiThreadedHttpConnectionManager objects for different invocations. Actually this stops
axis2 uses keep alive by default. In order to switch on keep alive one have to set the same
http client for all the invocations as show below.

you can verify whether actually it uses keep alive or not using tcpmon. It should send all
the messages using only one tcp connection.


------------------------------------------------------------------------------------------------------------------------------------
MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
            HttpConnectionManagerParams params = new HttpConnectionManagerParams();
            HostConfiguration hostConfiguration = new HostConfiguration();
            hostConfiguration.setHost("localhost", 8085);
            params.setMaxTotalConnections(100);
            params.setMaxConnectionsPerHost(hostConfiguration, 25);
            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}
                }
            }

> CLOSE_WAIT slowly building up over the period of time.
> ------------------------------------------------------
>
>                 Key: AXIS2-2883
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2883
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: client-api
>    Affects Versions: 1.1
>         Environment: Operating System : Solaris 
> Axis2 Version : 1.1
> Application Server : weblogic 8.1 SP6
> Using with Cocoon and weblogic DSP
>            Reporter: Lakshmanan Venkatachalam
>            Assignee: Deepal Jayasinghe
>            Priority: Critical
>
> I am experiencing theconstant increase in close wait in the production environment over
the period 7 days. 
> We are using Synchronous webservices and we are calling two webservices 24 times every
day. We have allocated the maximum of 1.5 GB per application instance and we have two application
instances. We are utilizing maximum of 250 - 300 MB in average. So Full GC never runs in our
environment.
> It seems like the client API ServiceClient.java is not cleaning up the resources associated
with this component. We are creating the new ServiceClient component on every call we have
for webservices. Though we have called the cleanup() method at the end of every call to the
webservices. At times its not getting executed.
> But when we force garabage collection from the application, it was able to clear all
the CLOSE_WAIT components. Since we have similar cleanup() call on finalize() method, it is
able to do proper clean up when GC is collecting these objects.
> Forcing GC cannot be a solution, I like to hear from axis2 experts on how we can resolve
this problem properly and what could be the cause for this happening.
> Below is our client code for your reference.
> private WebServiceResponse invokeWebservice(OMElement inputElement,
> 			Options options) throws WebServiceInvokerException {
> 		ServiceClient serviceClient = null;
> 		try {
> 			serviceClient = new ServiceClient();
> 			serviceClient.setOptions(options);
> 			// This following line of code is used when we are using
> 			// WS-Addressing. User has to make sure the addressing MAR file in
> 			// class path before enable the following line of code
> 			//
> 			// serviceClient.engageModule(new QName(
> 			// org.apache.axis2.Constants.MODULE_ADDRESSING));
> 			// Invoking synchrounous webservice
> 			//
> 			OMElement result = serviceClient.sendReceive(inputElement);
> 			
> 			OMNode firstOMChild = result.getFirstOMChild();
> 			// Conver the OMelements to XML String
> 			//
> 			Writer stringWriter = new StringWriter();
> 			firstOMChild.serialize(stringWriter);
>             serviceClient.cleanup();
> 			stringWriter.flush();
> 			// Return the Axis2WebserviceResponse
> 			//
> 			return new Axis2WebServiceResponse(stringWriter.toString());
> 		} catch (AxisFault afe) {
> 			throw new WebServiceInvokerException(afe);
> 		} catch (XMLStreamException xse) {
> 			throw new WebServiceInvokerException(xse);
> 		} catch (IOException ioe) {
> 			throw new WebServiceInvokerException(ioe);
> 		} finally {
> 			try {
> 				serviceClient.cleanup();
>                 serviceClient=null;
> 			} catch (AxisFault axisFault) {
> 				//
> 			}
> 		}
> 	}
> }
> options are:
> Options options = new Options();
> 		options.setTo(targetEPR);
> 		options.setUseSeparateListener(false);
> 		options.setAction(wsRequest.getAction());
> 		options.setTimeOutInMilliSeconds(600000);
> 		options.setTransportInProtocol("http");
> 		options.setProperty(org.apache.axis2.context.MessageContextConstants.CHUNKED, org.apache.axis2.transport.http.HTTPConstants.HEADER_TRANSFER_ENCODING);
>  

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


Mime
View raw message