Proxy settings http.proxyHost and http.proxyPort ignored by Java? 

Joined:
04/09/2007
Posts:
784

December 03, 2013 09:14:45    Last update: December 03, 2013 09:14:45
To test the effects of proxy settings http.proxyHost and http.proxyPort, I set these values to a non-existing proxy server:
java -Dhttp.proxyHost=example.com -Dhttp.proxyPort=8 GetPage http://www.google.com


To my surprise, the Google is retrieved successfully! Is Java ignoring these settings?

It turns out that Java tries to fetch the URL directly after the proxy connection fails. If a working proxy is found at proxyHost:proxyPort, then the request is routed through the proxy, otherwise a direct connection is tried.

The settings are documented here: http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html.

For HTTPS use these properties:
  • htttps.proxyHost
  • htttps.proxyPort
Share |
| Comment  | Tags