You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "robert lazarski (JIRA)" <ji...@apache.org> on 2006/09/21 23:36:24 UTC

[jira] Commented: (AXIS2-935) Connections are not properly released causing them to stick in the "CLOSE_WAIT" state and cause "Too many files open"

    [ http://issues.apache.org/jira/browse/AXIS2-935?page=comments#action_12436653 ] 
            
robert lazarski commented on AXIS2-935:
---------------------------------------

I can't reproduce this via 'netstat -anc | grep CLOSE_WAIT' on linux. Recently another user claimed this was occurring: 

http://marc.theaimsgroup.com/?l=axis-user&m=115868315001899&w=2

Here's the client I'm using for just a typical service with MR RawXMLINOutMessageReceiver . 

package client;

import java.io.StringWriter;

import javax.xml.stream.XMLOutputFactory;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
// jira imports
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.Constants;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.client.OperationClient;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.namespace.QName;
import org.apache.axis2.wsdl.WSDLConstants;

public class TestCW {
	  /** Access point inside the servlet container. **/
    private static EndpointReference targetEPR =
        new EndpointReference(
                "http://localhost:8080/axis2/services/SpringAwareService");

    /**
     * Simple axis2 client.
     *
     * @param args Main
     */
    public static void main(String[] args) {
        try {
            ServiceClient serviceClient = new ServiceClient();

            Options options = new Options();
            options.setTo(targetEPR);
            /* code to test close_wait jira axis2-935 */
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            options.setProperty(HTTPConstants.SO_TIMEOUT,1000);
            options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.FALSE);
            options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 5000);

            MessageContext requetMessageContext = new MessageContext();
            requetMessageContext.setEnvelope(getRequestEnvelope());

            OperationClient opClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
            opClient.addMessageContext(requetMessageContext);
            opClient.setOptions(options);
            /* end extra jira code */

            opClient.execute(true);

            SOAPEnvelope result = opClient.getMessageContext(
               WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();

            printResult(result);
        } catch (Exception ex) {
            ex.printStackTrace();       	
        }
    }    

    public static SOAPEnvelope getRequestEnvelope() {
        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope envelope = fac.getDefaultEnvelope();
        OMNamespace omNs = fac.createOMNamespace(
            		"http://springExample.org/example1", "example1");
        OMElement method = fac.createOMElement("getValue", omNs);
        OMElement value = fac.createOMElement("Text", omNs);
        value.addChild(fac.createOMText(value, "Some String "));
        method.addChild(value);
        envelope.getBody().setFirstChild(method);

        return envelope;
    }

    public static void printResult(SOAPEnvelope result) {
        try {
            if (result != null) {
                //OMElement resultOM = result.getBody().getFirstChildWithName(new QName("example1"));
                OMElement resultOM = result.getBody();
                StringWriter writer = new StringWriter();
                resultOM.serialize(XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(writer));
                writer.flush();
                System.out.println("Response: " + writer.toString());
            } else
                System.out.println("Result is null");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

If there is some way to trigger the issue please comment. 

> Connections are not properly released causing them to stick in the "CLOSE_WAIT" state and cause "Too many files open"
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-935
>                 URL: http://issues.apache.org/jira/browse/AXIS2-935
>             Project: Apache Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.0
>         Environment: Weblogic 8.1.2, Solaris 8 (dont ask!)
>            Reporter: Jeff Peterson
>         Assigned To: Deepal Jayasinghe
>            Priority: Blocker
>         Attachments: AXIS2-935.patch
>
>
> It appears that org.apache.axis2.transport.http.SOAPOverHTTPSender does not properly cleanup the http post connection after payload has been sent.
> The symptoms of this problem show up in `netstat` as literally hundreds of connections in the "CLOSE_WAIT" state.  On a busy server this can cause the application to report exceptions with the message "Too many open files."
> I looked in the source code for axis2 1.0 and discovered that in SOAPOverHTTPSender.java the releaseConnection() is never called on the postMethod variable.  This seems to be a likely candidate for the source of the issue.
> See SOAPOverHTTPSender.java:97-118

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org