File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes [Apache Httpclient]  Connection refused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "[Apache Httpclient]  Connection refused" Watch "[Apache Httpclient]  Connection refused" New topic

[Apache Httpclient] Connection refused

Iris Hoekstra

Joined: Aug 10, 2005
Posts: 29
We have built a small application based on Apache Httpclient to test the speed of our database connection. The problem is that we get 'Connection refused' errors at completely unpredictable moments.

We're creating 50 threads that each wait for a random number of miliseconds and then do this:

The 'executeQuery' method eventually does this:

The PostMethod is created like this:

Please let me know if this doesn't make sense. I find it hard to decide what to post and what to leave out.

Sometimes it starts throwing exceptions that look like this:

29-sep-2006 9:53:19 org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception ( caught when processing request: Connection refused: connect

If this happens we make it go through three more retries (of necessary). Sometimes that isn't enough and we get: Connection refused: connect
at Method)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(
at org.apache.commons.httpclient.HttpClient.executeMethod(
at org.apache.commons.httpclient.HttpClient.executeMethod(

I have been trying to figure this one out for more than a week but I still don't understand
what *really* causes a 'connection refused'. I guess that is because there may be many different causes.

Any clues pointing me in the right direction will be much appreciated.
[ September 29, 2006: Message edited by: Iris Hoekstra ]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Moving to the Other Open Source Projects forum.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: [Apache Httpclient] Connection refused
It's not a secret anymore!