• Post Reply Bookmark Topic Watch Topic
  • New Topic

useSystemProxies breaks sockets?  RSS feed

Simon Havenith
Posts: 4
  • Mark post as helpful
  • send pies
  • 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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!