Browserermob-proxy 'server is refusing connections

Selenium Webdriver 2.42.2, browserermob-proxy Beta 9, Windows 7 / Firefox

I am trying to call the browserermob-proxy API to capture HTTP requests and thereafter. But I am getting the following errors:

The proxy server is refusing connections

      

Firefox is configured to use a proxy server that refuses connections.

Check the proxy settings to make sure that they are correct.
Contact your network administrator to make sure the proxy server is working.

      

Does anyone know if this could be a network problem, we do not use proxy servers on our network. I also run browserermob-proxy.bat -port 9090 to start the server. Below is the sample code I have tried:

public void setDriver(String browser,String environment,String platform) throws Exception {
ProxyServer server = null;

// start the proxy
server = new ProxyServer(9091);
server.start();
server.setCaptureHeaders(true);
server.setCaptureContent(true);

// set the Selenium proxy object
Proxy proxy = server.seleniumProxy();
//Proxy proxy = new Proxy();
//proxy.setHttpProxy("localhost:9091");

caps = DesiredCapabilities.firefox();
caps.setCapability(CapabilityType.PROXY,proxy);

server.newHar("test");

public void closeDriver() throws Exception {
Har har = server.getHar(); // browserMob proxy

FileOutputStream fos = new FileOutputStream("C:/Downloads/browserMob.har");
har.writeTo(fos); // browserMob proxy
server.cleanup(); // browserMob proxy
server.stop(); // browserMob proxy

this.driver.quit();

      

+3


source to share


2 answers


There are 2 options: 1) Browsermob proxy server did not start; 2) The proxy server started with incorrect parameters;

If you have the second problem, try this code:



                server = new ProxyServer(9091);     
                server.setLocalHost(InetAddress.getByName("localhost"));
                server.start();
                server.setCaptureContent(true);
                server.setCaptureHeaders(true);

      

+1


source


As described above, but a few thoughts:



  • Try using Firefox profile:
    As described here: Webdriver and proxy for firefox

  • Try adding an address parameter: InetAddress.getLocalHost()

  • Make sure the port is open.

0


source







All Articles