• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

connection timed out with commons httpclient

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/");



Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic