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 ji...@apache.org on 2004/06/06 08:02:53 UTC

[jira] Closed: (AXIS-238) Connections not closed in http client code.

Message:

   The following issue has been closed.

   Resolver: Davanum Srinivas
       Date: Sat, 5 Jun 2004 11:02 PM

Latest CommonsHTTPSender behaves properly. 
---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/AXIS-238

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: AXIS-238
    Summary: Connections not closed in http client code.
       Type: Bug

     Status: Closed
 Resolution: FIXED

    Project: Axis
 Components: 
             Basic Architecture
   Fix Fors:
             current (nightly)
   Versions:
             current (nightly)

   Assignee: 
   Reporter: Brian Ewins

    Created: Tue, 30 Jul 2002 4:12 PM
    Updated: Sat, 5 Jun 2004 11:02 PM
Environment: Operating System: All
Platform: All

Description:
See thread entitled 'Socket problems' on axis-user, 30 July 2002.
Originally reported by Geza Szocs at nokia dot com.

"We ecountered that after a certain period of time (tipically 4-5 hours) the
webserver was not able to receive any more HTTP requests. However the
client-side was still sending SOAP requests to other servers. Analyzing with
netstat we found that around 2000 sockets have been created by Axis client
framework, which were still active, and this number didn't want to decrease. It
seemed like this client framework was eating up all resources of the OS
(sockets). I also checked to source code of HTTPSender, I see that socket are
not closed there."

I've had a look at the source of both org.apache.axis.transport.http.HttpSender
and CommonsHttpSender. Neither are closing sockets when they're done. I guess
the intention is to leave the read socket open to delay reading as long as
possible, but closing the socket inputstream doesn't close the socket.
Similarly, the HttpClient's getResponseBodyAsStream() doesnt return a stream
that closes the connection when the stream is closed.

Unless you intend keeping the connections open and re-using them (which would
require more changes to the code) can I suggest wrapping these like so...

<inserts teach-granny-to-suck-eggs code> :)

InputStream stream=new FilterInputStream(method.getResponseBodyAsStream()) {
   public void close() throws java.io.IOException {
       try {
       super.close();
       } finally {
       conn.close(); // needs to be made final to work.
       }
   }
};
Message outMsg = new Message(stream,
                    false, contentType, contentLocation); 

... also close the connection when any exception is thrown.


---------------------------------------------------------------------
JIRA INFORMATION:
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

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira