首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >browsermob-proxy‘服务器拒绝连接’错误

browsermob-proxy‘服务器拒绝连接’错误
EN

Stack Overflow用户
提问于 2014-08-14 20:25:08
回答 2查看 3.6K关注 0票数 3

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

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

代码语言:javascript
复制
The proxy server is refusing connections

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

代码语言:javascript
复制
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来启动服务器。下面是我尝试过的代码示例:

代码语言:javascript
复制
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();
EN

回答 2

Stack Overflow用户

发布于 2014-08-19 19:52:50

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

如果您有第二个问题,请尝试以下代码:

代码语言:javascript
复制
                server = new ProxyServer(9091);     
                server.setLocalHost(InetAddress.getByName("localhost"));
                server.start();
                server.setCaptureContent(true);
                server.setCaptureHeaders(true);
票数 1
EN

Stack Overflow用户

发布于 2016-05-14 10:05:25

如上所述,但有几个想法:

  1. 尝试使用Firefox配置文件:

如此处所述:Webdriver and proxy server for firefox

  • Try to add address parameter by:InetAddress.getLocalHost()

  • Make确保端口已打开。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25308058

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档