Mingyu
Mingyu

Reputation: 33399

Pass BrowserMob Proxy to Sauce Labs - "The proxy server is refusing connections" Error

I have been trying to pass BrowserMob proxy to Sauce Labs with no luck.

Here's what I have tried:

The following post provides a general guide line regarding how to make it work, but I keep getting "The proxy server is refusing connections" error.

Upvotes: 6

Views: 3007

Answers (2)

Mingyu
Mingyu

Reputation: 33399

I figured out the answer.

  • Start Sauce Connect, and pass proxy server information

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

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

    nc -l 9091
    
  • Run 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:[email protected]:80/wd/hub"),
            capabillities);
    

    The Java Client should starts a proxy at Port 9091. Unlike using FirefoxDriver directly, proxy should not be set in capabilities.

Upvotes: 6

TinyTimZamboni
TinyTimZamboni

Reputation: 5345

I could be wrong, but try a different port (like 9090). SauceConnect only proxies some ports for localhost as per the docs

Upvotes: 0

Related Questions