ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> apache-soap-dev
apache-soap-dev
[jira] Created: (SOAP-170) Socket is not closed after apache.axis SOAP call and resulted in too many CLOSE_WAIT state
by Jiping Yao other posts by this author
Aug 21 2006 11:00AM messages near this date
Re: Board Report for Sept 2006 | [jira] Commented: (SOAP-170) Socket is not closed after apache.axis SOAP call and resulted in too many CLOSE_WAIT state
SERVICES Socket is not closed after apache.axis SOAP call and resulted in too many CLOSE_WAI
T state
------------------------------------------------------------------------------------------

                 Key: SOAP-170
                 URL: http://issues.apache.org/jira/browse/SOAP-170
             Project: SOAP
          Issue Type: Bug
         Environment: Both Windows and UNIX
            Reporter: Jiping Yao
            Priority: Critical


I am not be able to send email to axis-dev@[...].org so I opend it as bug regport.

Currently, I ran into the problem with every socket not closed as shown by numerous SOCKET_W
AIT state after making SOAP call with apache.axis and those states are stayed there forever.
  Once we reach to the maximum number for SOCKET_WAIT state (operating system could not allo
cate any more connections as indicated by Too many open files), we could not make any SOAP c
all until we restart JVM.

Here is the original code where "currentMessage = currMsg;" could cuases the sokcet leaking 
(see JYao's comment)

public class SOAPPart extends javax.xml.soap.SOAPPart implements Part
{
	.
	.
	.
    private void setCurrentForm(Object currMsg, int form) {
        if (log.isDebugEnabled()) {
            String msgStr;
            if (currMsg instanceof String) {
                msgStr = (String)currMsg;
            } else {
                msgStr = currMsg.getClass().getName();
            }
            log.debug(Messages.getMessage("setMsgForm", formNames[form],
                    "" + msgStr));
        }

        // only change form if allowed
        if (isFormOptimizationAllowed()) {
            currentMessage = currMsg;   // JYao's comment: socket is leaking here if current
Message was an instance of SocketInputStream.
            currentForm = form;
            if (currentForm == FORM_SOAPENVELOPE) {
                    currentMessageAsEnvelope = (org.apache.axis.message.SOAPEnvelope) currMs
g;
            }
        }
    }


The following is what I changed for the same function within the block between of begin and 
end. After deployed recompiled code, all sockets allocated for apache.axix SOAP call are pro
perly closed and the CLOSE_WAIT state associated with SOAP call is no longer seen by netstat
 -n in windows.

public class SOAPPart extends javax.xml.soap.SOAPPart implements Part
{
	.
	.
	.

    private void setCurrentForm(Object currMsg, int form) {
        if (log.isDebugEnabled()) {
            String msgStr;
            if (currMsg instanceof String) {
                msgStr = (String)currMsg;
            } else {
                msgStr = currMsg.getClass().getName();
            }
            log.debug(Messages.getMessage("setMsgForm", formNames[form],
                    "" + msgStr));
        }

        // only change form if allowed
        if (isFormOptimizationAllowed()) {

           
	// begin of JYao's change: 
	
	// currentMessage should be closed if it is an instance of SocketInputStream
            // before to take any new instance of whatever SOAP message, otherwise the socke
t might be leaked
            if (currentMessage instanceof SocketInputStream)
            {
                SocketInputStream socketInput = (SocketInputStream) currentMessage;
                try
                {
                    socketInput.close();   // the socket is properly closed 
                }
                catch (IOException e)
                {
                    // never got there
                }
            } 

	// end of JYao's change

            currentMessage = currMsg; // JYao: safely take any other SOAP message
            currentForm = form;
            if (currentForm == FORM_SOAPENVELOPE) {
                    currentMessageAsEnvelope = (org.apache.axis.message.SOAPEnvelope) currMs
g;
            }
        }
    }
    . 
    .
    .
}

I am not sure if this is a bug or intended by authors. If it is not a bug, please give us ad
vice how to get those sockets closed after each SOAP call.

Thanks,
Jiping Yao

-- 
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: soap-dev-unsubscribe@[...].org
For additional commands, e-mail: soap-dev-help@ws.apache.org
Thread:
Jiping Yao
soap-dev

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved