Hello Clement,

HttpClient is not thread-safe by default, but fortunately it's quite easy to make it so. Please have a look at the threading guide for some more info <http://jakarta.apache.org/commons/httpclient/threading.html>.

Mike

On Oct 6, 2004, at 5:36 PM, Clement Soullard wrote:

Hello,

I am using http client to program a proxy that record my requests into an XML file. For this I use http client to submit the requests to the server (Tomcat 5.0.18).
Http Client is used in a multi thread way so I can keep the session information in my client.


But I get two kind of error : IlleggalStateException, and IOException. Those error does not occurs when I write synchronize before the executeMethode that make me think this is a bug of HttpClient in multithreaded mode.

In summary, I get :

Unable to parse header: HTTP/1.1 200 OK
-  that seems strange to me

java.lang.IllegalStateException: Connection is not open
- The static locks and instances are so intricated that I have absolutely have no idea what causes such errors.


And also :

The server localhost failed to respond with a valid HTTP response
- That could be explained if my server was on an heavy load, but I am single user of the proxy so I know this is not enought to put down my server down.


Finally, it seems that the synchronize keyword before my executeMethod doesn't make the HttpClient so slow but it works well in that mode.

Here, are three types of stacktraces that occurs :

org.apache.commons.httpclient.ProtocolException: The server localhost failed to respond with a valid HTTP response
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodB ase.java:1838)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBas e.java:1587)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.jav a:998)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpM ethodDirector.java:392)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMeth odDirector.java:178)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 392)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 324)
at proxy.server.RequestHandlerHttpClient.processRequest(RequestHandlerHttp Client.java:160)
at proxy.server.RequestHandlerHttpClient.run(RequestHandlerHttpClient.java :79)
at java.lang.Thread.run(Unknown Source)


GRAVE: http://us.update.companion.yahoo.com/slv/v4/ 2.html?.pc=&.a=0&.ta=cgnone,ccnone,cius,cv5_3_12,cp&.cv=1&.cs=b,c94c6ba 69c94d410,p,448d7c721d9dddab&t=6313000: org.apache.commons.httpclient.ProtocolException: Unable to parse header: HTTP/1.1 200 OK
org.apache.commons.httpclient.ProtocolException: Unable to parse header: HTTP/1.1 200 OK
at org.apache.commons.httpclient.HttpParser.parseHeaders(HttpParser.java: 189)
at org.apache.commons.httpclient.HttpMethodBase.readResponseHeaders(HttpMe thodBase.java:1782)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBas e.java:1589)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.jav a:998)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpM ethodDirector.java:392)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMeth odDirector.java:178)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 392)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 324)
at proxy.server.RequestHandlerHttpClient.processRequest(RequestHandlerHttp Client.java:160)
at proxy.server.RequestHandlerHttpClient.run(RequestHandlerHttpClient.java :79)
at java.lang.Thread.run(Unknown Source)


GRAVE: http://us.update.companion.yahoo.com/slv/v4/ 2.html?.pc=&.a=0&.ta=cgnone,ccnone,cius,cv5_3_12,cp&.cv=1&.cs=b,c94c6ba 69c94d410,p,448d7c721d9dddab&t=6132640: java.lang.IllegalStateException: Connection is not open
java.lang.IllegalStateException: Connection is not open
at org.apache.commons.httpclient.HttpConnection.assertOpen(HttpConnection. java:1244)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.ja va:1092)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodB ase.java:1824)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBas e.java:1587)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.jav a:998)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpM ethodDirector.java:392)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMeth odDirector.java:178)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 392)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 324)
at proxy.server.RequestHandlerHttpClient.processRequest(RequestHandlerHttp Client.java:160)
at proxy.server.RequestHandlerHttpClient.run(RequestHandlerHttpClient.java :79)
at java.lang.Thread.run(Unknown Source)


I didnt find any bugs of that kind in bugzilla... Thanks for your help to let me understand the reasons...

Clement Soullard,


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to