wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes connection timed out with commons httpclient Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "connection timed out with commons httpclient" Watch "connection timed out with commons httpclient" New topic

connection timed out with commons httpclient

karthikeyan sivanantham

Joined: Dec 03, 2008
Posts: 1
Hi all,

I'm trying to post to a website using the apache common httpclient util and I'm using borrowed code from the net to power my app, when I run my app, I get a connection time out error. my app is sitting behing a corporate proxy and I guess my app is not able to reach the website through the proxy, can someone let me know how to get through?

I'm posting my code and the error below



Dec 3, 2008 6:23:26 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
Dec 3, 2008 6:23:26 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Exception in thread "main" java.net.NoRouteToHostException: No route to host: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)


package site_login_eg;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

public class Main

public static void main(String[] args) throws Exception {

HttpClient client = new HttpClient();

GetMethod getPage = new GetMethod("http://www.hackthissite.org");


PostMethod postLogin = new PostMethod("http://www.hackthissite.org/pages/index/index2.php");

NameValuePair[] data = {
new NameValuePair("txt_username", "MYUSERNAME"),
new NameValuePair("txt_password", "MYPASSWORD"),
new NameValuePair("btn_submit","Login")




//this is a request to a page that requires authentication
GetMethod getPage2 = new GetMethod("http://www.hackthissite.org/missions/basic/");



I agree. Here's the link: http://aspose.com/file-tools
subject: connection timed out with commons httpclient
Similar Threads
"Connection timed out" with HttpClient.
Catalina.stop: java.net.ConnectException: Connection refused: connect
Login and Download file over https
prob with Jakarta HttpClient & HostConfiguration