axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11296] New: - Connections not closed in http client code.
Date Tue, 30 Jul 2002 16:12:08 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11296>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11296

Connections not closed in http client code.

           Summary: Connections not closed in http client code.
           Product: Axis
           Version: current (nightly)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Basic Architecture
        AssignedTo: axis-dev@xml.apache.org
        ReportedBy: Brian.Ewins@btinternet.com


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.

Mime
View raw message