You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by "Vincent Oostindiƫ (JIRA)" <so...@ws.apache.org> on 2006/10/18 12:49:35 UTC

[jira] Commented: (SOAP-170) Socket is not closed after apache.axis SOAP call and resulted in too many CLOSE_WAIT state

    [ http://issues.apache.org/jira/browse/SOAP-170?page=comments#action_12443223 ] 
            
Vincent Oostindiƫ commented on SOAP-170:
----------------------------------------

I can confirm this issue. We have a web application that also acts as a client for a remote Web Service. The client was generated automatically, and uses Axis.

Every call to the remote service adds a new socket with state CLOSE_WAIT. It's just a matter of time before there are no longer any sockets available.

I've been able to reproduce the problem with Axis 1.3 and Axis 1.4.

The code from Jiping Yao resolves it. We've patched Axis 1.3, and now the problem doesn't occur anymore.

> Socket is not closed after apache.axis SOAP call and resulted in too many CLOSE_WAIT 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@ws.apache.org so I opend it as bug regport.
> Currently, I ran into the problem with every socket not closed as shown by numerous SOCKET_WAIT 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 allocate any more connections as indicated by Too many open files), we could not make any SOAP call 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 currentMessage was an instance of SocketInputStream.
>             currentForm = form;
>             if (currentForm == FORM_SOAPENVELOPE) {
>                     currentMessageAsEnvelope = (org.apache.axis.message.SOAPEnvelope) currMsg;
>             }
>         }
>     }
> 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 properly 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 socket 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) currMsg;
>             }
>         }
>     }
>     . 
>     .
>     .
> }
> I am not sure if this is a bug or intended by authors. If it is not a bug, please give us advice 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@ws.apache.org
For additional commands, e-mail: soap-dev-help@ws.apache.org