hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "linea@libero.it" <li...@libero.it>
Subject Re: HttpRecoverableException
Date Fri, 31 Oct 2003 11:32:07 GMT
Hi, I am running a multithreaded application in which each thread executes 
PostMethod in sequence. This is the relevant part of httpclient classes, in 
which Checker273 gets java.net.SocketTimeoutException and Checker34 gets
org.apache.commons.httpclient.HttpConnection$ConnectionTimeoutException:

...
20031031 11:59:11,055 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.open()
20031031 11:59:14,380 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.print(String)
20031031 11:59:14,380 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.write(byte[])
20031031 11:59:14,380 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.write(byte[], int, int)
20031031 11:59:14,380 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.addRequestHeaders(HttpState, HttpConnection)
20031031 11:59:14,380 DEBUG [Checker273] methods.ExpectContinueMethod - enter 
ExpectContinueMethod.addRequestHeaders(HttpState, HttpConnection)
20031031 11:59:14,381 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.addContentLengthRequestHeader(HttpState, HttpConnection)
20031031 11:59:14,381 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.getRequestContentLength()
20031031 11:59:14,381 DEBUG [Checker273] methods.PostMethod - enter 
PostMethod.hasRequestContent()
20031031 11:59:14,381 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.hasRequestContent()
...
20031031 11:59:14,381 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.flushRequestOutputStream()
20031031 11:59:14,389 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.writeRequestBody(HttpState, HttpConnection)
20031031 11:59:14,389 DEBUG [Checker273] methods.PostMethod - enter 
PostMethod.hasRequestContent()
20031031 11:59:14,417 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.hasRequestContent()
20031031 11:59:14,417 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.getRequestContentLength()
20031031 11:59:14,417 DEBUG [Checker273] methods.PostMethod - enter 
PostMethod.hasRequestContent()
20031031 11:59:14,417 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.hasRequestContent()
20031031 11:59:14,417 DEBUG [Checker273] methods.PostMethod - enter 
PostMethod.renerateRequestBody()
20031031 11:59:14,417 DEBUG [Checker273] methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.renerateRequestBody()
20031031 11:59:14,417 DEBUG [Checker273] methods.EntityEnclosingMethod - Using 
buffered request body
20031031 11:59:14,417 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.getRequestOutputStream()
20031031 11:59:14,417 DEBUG [Checker273] methods.EntityEnclosingMethod - Request 
body sent
20031031 11:59:14,417 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.flushRequestOutputStream()
20031031 11:59:14,417 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.readLine(
)
...
20031031 12:00:14,507 DEBUG [Checker273] httpclient.HttpConnection - enter 
HttpConnection.releaseConnection()
20031031 12:00:14,568 DEBUG [Checker273] httpclient.HttpConnection - Releasing 
connection back to connection manager.
20031031 12:00:14,647 DEBUG [Checker273] 
httpclient.MultiThreadedHttpConnectionManager - enter 
HttpConnectionManager.releaseConnection(HttpConnection)
20031031 12:00:14,664 DEBUG [Checker273] 
httpclient.MultiThreadedHttpConnectionManager - Freeing connection, 
hostConfig=HostConfiguration[host=193.204.123.96, protocol=http:80, port=8000]
...
20031031 11:59:14,513 DEBUG [Checker34] httpclient.HttpConnection - enter 
HttpConnection.open()
20031031 11:59:44,522 WARN  [Checker34] httpclient.HttpConnection - The host 
193.204.123.96:8000 (or proxy null:-1) did not accept the connection within 
timeout of 30000 milliseconds
20031031 11:59:44,522 DEBUG [Checker34] httpclient.HttpConnection - enter 
HttpConnection.releaseConnection()
20031031 11:59:44,522 DEBUG [Checker34] httpclient.HttpConnection - Releasing 
connection back to connection manager.
20031031 11:59:44,522 DEBUG [Checker34] 
httpclient.MultiThreadedHttpConnectionManager - enter 
HttpConnectionManager.releaseConnection(HttpConnection)
20031031 11:59:44,522 DEBUG [Checker34] 
httpclient.MultiThreadedHttpConnectionManager - Freeing con
nection, hostConfig=HostConfiguration[host=193.204.123.96, protocol=http:80, 
port=8000]
20031031 11:59:44,522 DEBUG [Checker34] 
httpclient.MultiThreadedHttpConnectionManager - enter HttpC
onnectionManager.ConnectionPool.getHostPool(HostConfiguration)
20031031 11:59:44,522 DEBUG [Checker34] 
httpclient.MultiThreadedHttpConnectionManager - Notifying no-one, there are no 
waiting threads

And this is the corresponding application log, where the exceptions are finally 
catched:

  20031031 11:59:44,424 WARN  [Checker273] persistence.CheckPerformer - Read 
Timeout occurred while c
ontacting proxy..
java.net.SocketTimeoutException: Read timed out
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.net.SocketInputStream.read(SocketInputStream.java:182)
         at java.io.FilterInputStream.read(FilterInputStream.java:66)
         at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
         at 
org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:109)
         at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:135)
         at 
org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1049)
         at 
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.r
eadLine(MultiThreadedHttpConnectionManager.java:1055)
         at 
org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1828)
         at 
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1604)
         at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:997)
         at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethodForHost(HttpMethodDirector
.java:308)
         at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:1
38)
         at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:469)
         at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:355)
         at org.medra.persistence.CheckPerformer.checkDoi(CheckPerformer.java:316)
         at org.medra.persistence.Checker.run(Checker.java:96)
...
20031031 11:59:44,522 ERROR [Checker34] persistence.CheckPerformer - IOException 
occurred while con
tacting proxy..
org.apache.commons.httpclient.HttpConnection$ConnectionTimeoutException
         at 
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:734)
         at 
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.o
pen(MultiThreadedHttpConnectionManager.java:1020)
         at 
org.apache.commons.httpclient.HttpMethodDirector.establishValidOpenConnection(HttpMethod
Director.java:247)
         at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethodForHost(HttpMethodDirector
.java:300)
         at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:1
38)
         at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:469)
         at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:355)
         at org.medra.persistence.CheckPerformer.checkDoi(CheckPerformer.java:316)
         at org.medra.persistence.Checker.run(Checker.java:96)

I have one question more:
in my application each thread sends a POST request to the same server, which, 
depending on the frequency of these requests, can become unavailable. When this 
occurs I start getting a lot of these timeout exceptions. I have noticed that at 
this point the system max open files limit is reached, as this exception starts 
to be thrown:
20031031 12:00:09,529 ERROR [Checker143] persistence.CheckPerformer - 
IOException occurred while contacting proxy..
java.net.SocketException: Too many open files
         at java.net.Socket.createImpl(Socket.java:313)
         at java.net.Socket.<init>(Socket.java:286)
         at java.net.Socket.<init>(Socket.java:119)
         at 
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(Default
ProtocolSocketFactory.java:105)
         at 
org.apache.commons.httpclient.HttpConnection$1.doit(HttpConnection.java:675)
         at 
org.apache.commons.httpclient.HttpConnection$SocketTask.run(HttpConnection.java:1282)
         at java.lang.Thread.run(Thread.java:536)

It's strange that this happens just when a lot of timeouts occurr. Is it 
possible that HttpConnectionManager is not able to close the timed-out sockets 
when a timeout occurs?

thanks a lot,
Fabio



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message