The real problem is that Java assumes that the check "Use the same proxy server for all protocols" also affects the SOCKS proxy server (I don’t know the logic of this dialog on Windows, but it is at least confusing) If the check is installed, you activate proxies for both HTTP and SOCKS, which is unlikely to be the desired configuration. One way to fix it is to uncheck the box and leave the SOCKS field blank.
Finally, I decided to create a ProxySelector that first calls the default selector, and if it finds the same configuration for HTTP and SOCKS connections, it will skip the SOCKS proxy.
public class SocksFixerProxySelector extends ProxySelector { ProxySelector base; public SocksFixerProxySelector() { base = ProxySelector.getDefault(); } @Override public List<Proxy> select(URI uri) { List<Proxy> baseList = base.select(uri); try { if (uri.getScheme().equals("socket")) { Proxy socksProxy = findByType(baseList, Type.SOCKS); if (socksProxy != null) { URI httpTestUri = new URI("http", uri.getHost(), uri.getPath(), uri.getFragment()); Proxy httpProxy = findByType(base.select(httpTestUri), Type.HTTP); if (httpProxy != null && socksProxy.address().equals(httpProxy.address())) {
Perhaps the best solution would be to check the registry and determine the correct settings, but I did not want to mess with the Windows code (and all these script parameters also looked bad)
Juan calero
source share