Skip BrowserMob proxy for Sauce Labs - "Proxy refuses connections" Error

I am trying to skip the BrowserMob proxy in Sauce Labs with no luck.

Here is what I tried:

  • Start proxy server

    sh browsermob-proxy -port 9090 
  • Run proxy

     curl -X POST http://localhost:9090/proxy {"port":9091} 
  • Launch the sauce connection and pass the proxy information

     java -jar Sauce-Connect.jar myname xxxxxx -p localhost:9091 
  • Launch Java Client

     ProxyServer proxyServer = new ProxyServer(9091); proxyServer.start(); Proxy proxy = proxyServer.seleniumProxy(); DesiredCapabilities capabillities = DesiredCapabilities.firefox(); capabillities.setCapability(CapabilityType.PROXY, proxy); capabillities.setCapability("version", "5"); capabillities.setCapability("platform", Platform.XP); this.driver = new RemoteWebDriver( new URL("http://myname: xxxxxx@ondemand.saucelabs.com :80/wd/hub"), capabillities); 

The following post contains a general reference article on how to make it work, but I keep getting a โ€œProxy refused connectionโ€ error.

+6
source share
2 answers

I understood the answer.

  • Launch Sauce Connect and send proxy information

     java -jar Sauce-Connect.jar myname xxxxxx -p localhost:9091 

    Running the above command will forward all requests to localhost port 9091, and you can use netcat to confirm.

     nc -l 9091 
  • Launch Java Client

     ProxyServer proxyServer = new ProxyServer(9091); proxyServer.start(); Proxy proxy = proxyServer.seleniumProxy(); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); // DO NOT set proxy for RemoteWebDriver // capabilities.setCapability(CapabilityType.PROXY, proxy); capabilities.setCapability("version", "5"); capabilities.setCapability("platform", Platform.XP); this.driver = new RemoteWebDriver( new URL("http://myname: xxxxxx@ondemand.saucelabs.com :80/wd/hub"), capabillities); 

    The Java client must start the proxy server on port 9091. Unlike using FirefoxDriver directly , the proxy should not be installed in features.

+6
source

I may be wrong, but try a different port (e.g. 9090 ). SauceConnect only proxies some ports for localhost according to docs

0
source

All Articles