Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2005

Tip: Looking for answers? Try searching our database.

Java HTTP proxies fail open?

Thread view: 
Acidus - 18 Jul 2005 04:51 GMT
Folks,

I've found some weird stuff that Java 1.5 does when using HTTP proxies,
and I don't know how to stop it.

To start out I'm using the pretty standard way to specify a proxy to
Java. IE:

Properties p = System.getProperties();
p.setProperty("proxySet", "true");
p.setProperty("proxyHost", "123.123.123.123");
p.setProperty("proxyPort", "8080");
System.setProperties(p);

I'm using a URLConnection and its InputStream to read from a webpage,
say http://www.google.com.

I'm also setting a Timeout for the URLConnection, and catching the
exception.

The problem is that if you specify a proxy that either doesn't exist or
is refusing connections, Java will make the URLConnection *directly* for
you. It doesn't throw an exception or in anyway tell you "oh, BTW, I'm
not using the proxy"

Using Ethereal I could see what happens.

-Send a SYN to the proxy that doesn't work
-Wait about .5 seconds
-Send another SYN to proxy that doesn't work
-wait number of seconds specified by connectionTimeout for URLConnection.
-Send SYN directly to target website (http://www.google.com)
-makes connection and does download directly between google and my computer

So my question is, does anyone know how to force java to use a proxy,
and only the proxy? Is there another way to get java to use proxies? Am
I screwed and have to send HTTP headers myself?

Thanks,
Acidus
--
Most Significant Bit Labs
www.msblabs.org
Chris Smith - 18 Jul 2005 05:45 GMT
> So my question is, does anyone know how to force java to use a proxy,
> and only the proxy? Is there another way to get java to use proxies? Am
> I screwed and have to send HTTP headers myself?

I'm not aware of a way to do this using URLConnection.  By using
URLConnection, you are giving up a measure of control and asking Java to
figure out the right thing for you.  If you don't like it's choices,
then you need a different API.

See Jakarta Commons HttpClient, which provides that lower level of
control.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.