gpt4 book ai didi

browsermob 代理 'server is refusing connections' 错误

转载 作者:行者123 更新时间:2023-12-02 03:33:26 24 4
gpt4 key购买 nike

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

我正在尝试调用 browsermob-proxy API 来捕获 http 网络请求,并在遵循此 example 之后.但是,我收到以下错误:

The proxy server is refusing connections

Firefox 配置为使用拒绝连接的代理服务器。

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

任何人都知道这是否可能是网络问题,我们不在我们的网络中使用代理服务器。我还运行了 browsermob-proxy.bat -port 9090 来启动服务器。以下是我尝试过的代码示例:

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();

最佳答案

有两种变体:1) Browsermob代理服务器没有启动;2) 代理服务器以错误的参数启动;

如果你有第二个问题,试试这个代码:

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

关于browsermob 代理 'server is refusing connections' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25308058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com