0

I need to use BMP for response/request analysis (selenium using).

On the local, all works fine, but when I try to execute on the server, I get the error:

enter image description here

I use several variants for proxy creation:

  private void startProxyServer(){
      BrowserProxySniffing.startProxyServer(BrowserProxySniffing.IP_FOR_PROXY);
      browserMobProxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT);
      browserMobProxy.newHar();
  }

class BrowserProxySniffing{
  .......

  public static void startProxyServer(String address) {
    IP_FOR_PROXY = address;
    if (browserMobProxy.isStarted()) {
      browserMobProxy.stop();
    }
    try {
      browserMobProxy.start(9090, Inet4Address.getByName(address));//variant 1 (172.17.0.2 ip using)
      browserMobProxy.start(9090);//---variant 2 (the 0.0.0.0 ip addres created)
      browserMobProxy.start(9090, Inet4Address.getByName(address));//variant 3 (localhost ip using - works fine on the local mashine)

      useExclusivePort = browserMobProxy.getPort();
    } catch (Exception e) {
      e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
  }
}

I set Capabilities in the following way:

    startProxyServer(IP_FOR_PROXY);
    HashMap<String, Object> newCapabilities = BrowserProxySniffing.getProxyCapabilities();
    ChromeOptions options = new ChromeOptions();
    options.setCapability("seleniumProtocol", "WebDriver");

    Proxy seleniumProxy = new Proxy();
    seleniumProxy.setHttpProxy(IP_FOR_PROXY + ":" + useExclusivePort)
              .setSslProxy(IP_FOR_PROXY + ":" + useExclusivePort);

    newCapabilities.put(ChromeOptions.CAPABILITY,
            options.addArguments("--disable-gpu")
                    .addArguments("'--ignore-ssl-errors=yes")
                    .addArguments("--ignore-certificate-errors"));
    newCapabilities.put(CapabilityType.PROXY, seleniumProxy);
    newCapabilities.put(CapabilityType.ACCEPT_SSL_CERTS, true);
    setCapabilities(newCapabilities);

Conclusions

  1. Code works fine with localhost on the local machine. So I believe the code is right
  2. Code does not work with 127.0.0.1 on the server
  3. Code works successful early on the server (but fails after reloading)
  4. Code does not work with both localhost and 172.17.0.2 on the server

#How to use BMP on the server?

Additional info:

I found 172.17.0.2 in several ways:

a) arp -a: enter image description here

b) with the /jenkins_home/selenium.xml

c) with netstat -an

enter image description here

I also used all ip's what I found with netstat - all of them do not suitable (fails in browserMobProxy.start(9090, Inet4Address.getByName(address)) line, but 172.17.0.2 - success)

Valentyn Hruzytskyi
  • 1,772
  • 5
  • 27
  • 59
  • 1
    Why are you using the IP instead of a container name? – Tarun Lalwani Mar 10 '21 at 12:33
  • @TarunLalwani, Thanks for your question, but how I can use the container name for proxy creation?: `seleniumProxy.setHttpProxy(CONTAINER_NAME+ ":" + useExclusivePort)`?? – Valentyn Hruzytskyi Mar 10 '21 at 14:39
  • 1
    I assume that your BMP proxy and running selenium process is within in the same container? Can you explain your setup a bit. Also correct way in your case would be to use `browserMobProxy.start(9090);` – Tarun Lalwani Mar 10 '21 at 14:48

0 Answers0