Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java code failing to connect to Internet

Status
Not open for further replies.

mero

Programmer
Mar 22, 2001
4
US
I am writing Java code that attempts to make a connection to the Internet behind a proxy and fetches stock prices using the following code:

System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost",proxyHost);
System.getProperties().put("proxyPort",proxyPort);
URL sURL = new URL("String a = "myproxyname:myproxypassword";
String b = "Basic " + new sun.misc.BASE64Encoder().encode(a.getBytes());
HttpURLConnection sConnect = (HttpURLConnection)sURL.openConnection();
sConnect.setRequestProperty("Proxy-Authorization", b);

But when I attempt to connect, I get "java.net.NoRouteToHostException: Operation timed out". The site is definately up because I get to it with my browser ok using the same proxy name and password I use in the code. I am using JDK 1.2.2_005. What could be the problem? Thanks.
 
p.s- The code works fine if I attempt to connect to a site that's behind the proxy such as our Intranet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top