• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

useSystemProxies breaks sockets?

Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I would like to get the default proxy for HTTP using ProxySelector.getDefault() under Java 5. To do this you have to set the system property java.net.useSystemProxies e.g. System.setProperty("java.net.useSystemProxies","true")
This works, but when I then try to do a simple connect via a socket, the socket can no longer connect. If I don't set "java.net.useSystemProxies" my socket connection code works.

Oddly enough, if I go through a java.net.URL, I can connect just fine. It is my understanding that URL is a wrapper for an eventual socket connection, but there must be some magic going on that I haven't found in the sun.net.www.protocol.http packages.

I'm using org.apache.commons.httpclient, and it seems to suffer from this socket issue. I presume they make socket connections as well, and avoid using the java.net.URL.

How can I get the best of both worlds: dynamic proxy discovery and socket connections/org.apache.commons.httpclient?
[ November 09, 2005: Message edited by: Simon Havenith ]
    Bookmark Topic Watch Topic
  • New Topic