browsermob-proxy icon indicating copy to clipboard operation
browsermob-proxy copied to clipboard

"java.lang.RuntimeException: Could not resolve localhost"

Open chainloaded opened this issue 5 years ago • 0 comments

When trying to start the Selenium Web Driver with BrowserMob in Java I get the following exception: Exception in thread "main" java.lang.RuntimeException: Could not resolve localhost at net.lightbody.bmp.client.ClientUtil.getConnectableAddress(ClientUtil.java:114) at net.lightbody.bmp.client.ClientUtil.createSeleniumProxy(ClientUtil.java:70) at app.UseAccount.<init>(UseAccount.java:39) at app.Main.main(Main.java:65) Caused by: java.net.UnknownHostException: ????????: ???????? at java.net.InetAddress.getLocalHost(InetAddress.java:1506) at net.lightbody.bmp.client.ClientUtil.getConnectableAddress(ClientUtil.java:112) ... 3 more Caused by: java.net.UnknownHostException: ???????? at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324) at java.net.InetAddress.getLocalHost(InetAddress.java:1501) ... 4 more

My code is:

    BrowserMobProxy proxy = new BrowserMobProxyServer();
    proxy.start(1454);
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);


    System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\chromedriver.exe");

    ChromeOptions options1 = new ChromeOptions();
    options1.addArguments("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36");
    options1.addArguments("window-size=1700,900");
    options1.setCapability(CapabilityType.PROXY, seleniumProxy);

    WebDriver driver = new ChromeDriver(options1);

    proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
    
    proxy.newHar("Minecraft");

    driver.get("https://my.minecraft.net");
    
    Har har = proxy.getHar();
    
    System.out.println(har);`

What could be the reason for this error?

chainloaded avatar May 25 '20 23:05 chainloaded