0

I have a project that uses ChromeDriver and a proxy I pay for. There's no authentication on the proxy. It used to set the proxy just fine but now when I run it, if I check my public IP address it's still my address, not the proxy address. I'm not sure if Chrome changed something or what, but does anyone know how to get the proxy to work again?

                string proxyAddress = "https://xxx.xx.xx.xxx:xxxx"; //the x's are just masking the actual ip address

                ChromeDriverService cds = ChromeDriverService.CreateDefaultService();
                ChromeOptions co = new ChromeOptions();                
                if (!String.IsNullOrWhiteSpace(proxyAddress))
                {                  
                    co.Proxy = new Proxy(){
                        HttpProxy = proxyAddress,
                        Kind = ProxyKind.Manual,
                        IsAutoDetect = false                        
                    };
                }
                co.AddArgument("ignore-certificate-errors");
                co.AddArguments("chrome.switches", "--disable-extensions");
                cds.HideCommandPromptWindow = true;
                ChromeDriver drv;
                if (commandTimeout != null)
                {
                    drv = new ChromeDriver(cds, co, (TimeSpan)commandTimeout);
                }
                else
                {
                    drv = new ChromeDriver(cds, co);
                }

I've also tried this, but then every site Chrome says "This Site Can't be reached" and has the error code: ERR_NO_SUPPORTED_PROXIES.

string proxyAddress = "https://xxx.xx.xx.xxx:xxxx"; //the x's are just masking the actual ip address

                ChromeDriverService cds = ChromeDriverService.CreateDefaultService();
                ChromeOptions co = new ChromeOptions();                
                if (!String.IsNullOrWhiteSpace(proxyAddress))
                {                  
                     co.AddArgument(String.Format("--proxy-server={0}", proxyAddress));
                }
                co.AddArgument("ignore-certificate-errors");
                co.AddArguments("chrome.switches", "--disable-extensions");
                cds.HideCommandPromptWindow = true;
                ChromeDriver drv;
                if (commandTimeout != null)
                {
                    drv = new ChromeDriver(cds, co, (TimeSpan)commandTimeout);
                }
                else
                {
                    drv = new ChromeDriver(cds, co);
                }
chris-crush-code
  • 1,114
  • 2
  • 8
  • 17
  • Try use --proxy-server={0} – Emanuele Jun 14 '21 at 13:33
  • @Emanuele, sorry, I mistyped, that is what I tried in my second code section (I'll update it to reflect that). When I do that Chrome says "This site can't be reached" and has ERR_NO_SUPPORTED_PROXIES - this is for any site I try to go to, such as whatismyip.com – chris-crush-code Jun 14 '21 at 13:36
  • Have you tried this? https://stackoverflow.com/questions/11450158/how-do-i-set-proxy-for-chrome-in-python-webdriver – Emanuele Jun 14 '21 at 13:39
  • @Emanuele, thanks for your help, I didn't see anything in that question. I did end up finding this though, which solved the proble: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1605 – chris-crush-code Jun 14 '21 at 14:05

1 Answers1

0

To anyone running into the same issue, I managed to to get it to work by replacing

co.AddArgument(String.Format("--proxy-server={0}", proxyAddress));

with this

co.AddArgument(String.Format("--proxy-server=http://{0}:{1};https://{0}:{1}", proxy.Address.Host, proxy.Address.Port));

My only guess is that it needed to be set for both http and https.

chris-crush-code
  • 1,114
  • 2
  • 8
  • 17