You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Michael Remijan <mj...@yahoo.com> on 2011/06/09 16:34:15 UTC
More proxy questions
I have searched online for quite some time looking for information about httpclient connection through a proxy. Though I've found a lot of information I have not found a solution yet.
I have the same problem lots of others have. I'm using a library which uses httpclient however I do not have access to that library's code. Now need to be able to configure the proxy for httpclient in my App.
I looks like DefaultHttpParams is the way to go. I have this in my code...
HttpParams params = DefaultHttpParams.getDefaultParams();
params.setParameter("http.proxyHost", "SERVER_NAME");
params.setParameter("http.proxyPort", "PORT");
When I run my tests it fails with a timeout exception...
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1115)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at org.ferris.net.runner.HttpRequestRunner.executeMethod(HttpRequestRunner.java:211)
... 25 more
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 21.68 sec
How can I configure the proxy correctly?
Thanks in advance.