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:
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
- Code works fine with localhost on the local machine. So I believe the code is right
- Code does not work with 127.0.0.1 on the server
- Code works successful early on the server (but fails after reloading)
- 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:
b) with the /jenkins_home/selenium.xml
c) with netstat -an
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)