Skip to main content

Problem with proxy settings in Internet Explorer

2 replies [Last post]
vity01
Offline
Joined: 2006-03-25
Points: 0

Hello,
I use HttpClient 3.1 on Windows XP + Java 1.6_10.
I have following problem I can't figure out:
Connections are always created with Internet Explorer browser proxy settings, even if I don't set up proxy with HttpClient.
I tried to disable using browser settings by these switches:

<br />
        System.getProperties().put("proxySet", "false");<br />
        System.getProperties().put("proxyHost", "");<br />
        System.getProperties().put("http.proxySet", "false");<br />
        System.getProperties().put("http.proxyHost", "");<br />
        System.getProperties().put("http.proxyPort", "");<br />
        System.getProperties().put("socksProxyHost", "");<br />
        + their remove() variants<br />

but it doesn't help. They are simply ignored.
The problem is that connection created with browser settings does not work at all (connection timeout - although it works fine in the browser). I don't see proxyHost property in my System properties either (although the system proxy is used). It completely looks like JDK bug to me. When I disable proxy settings in IE while my app is running, I can connect succesfully => it's loaded from registry on the fly.

Does anyone know how to get rid off browser settings in the code?

Thanks for your advices

-Vity

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
solarix777
Offline
Joined: 2008-12-15
Points: 0

Hi,

Try this:

import java.net.ProxySelector;

ProxySelector.setDefault(null);

vity01
Offline
Joined: 2006-03-25
Points: 0

Yeah, that's it.
I explored code of the ProxySelector (a class I've never heard...), it pointed to [code]sun.net.spi.DefaultProxySelector[/code], where I found out this property:
[code]System.setProperty("java.net.useSystemProxies", "false");[/code]
which solves my problem.

Thank you Solarix