JMeter 记录:将 HTTP 代理更改为本地主机后出现 401 未经授权的响应

JMeter Recording: 401 Unauthorized response after changed HTTP proxy to localhost

我刚开始学习 JMeter。我正在尝试使用 JMeter 记录我公司的网站、.NET 网络应用程序。

我的问题是为了安全,要访问网站,我们必须将"Manual proxy configuration"配置为10.x.x.x:3128 .但是,要在 JMeter 中记录,我必须将配置更改为本地主机,端口 3128。

将配置更改为 localhost 后,我​​单击 HTTP 测试脚本记录器的开始按钮,然后单击任何链接,显示授权对话框,尽管我输入正确 username/password,但我不断收到 401 未经授权的错误。

我尝试使用 HTTP 授权管理器、HTTP 请求默认值或 HTTP 请求,但它们不起作用。

有人能帮帮我吗?

如果您的公司使用代理访问 Internet,您也可以 "tell" JMeter 使用此代理。所以需要进行如下配置:

  1. 将 JMeter 配置为使用您的代理通过以下 command-line 参数访问互联网(根据 documentation):

    If you are testing from behind a firewall/proxy server, you may need to provide JMeter with the firewall/proxy server hostname and port number. To do so, run the jmeter[.bat] file from a command line with the following parameters:

    -H [proxy server hostname or ip address]

    -P [proxy server port]

    -N [nonproxy hosts] (e.g. *.apache.org|localhost)

    -u [username for proxy authentication - if required]

    -a [password for proxy authentication - if required]

    Example : jmeter -H my.proxy.server -P 8000 -u username -a password -N localhost

  2. 添加 HTTP(S) Test Script Recorder 默认 端口 8080(或任何其他)

  3. 配置您的浏览器以使用 JMeter 主机 和端口 8080 访问互联网。如果在浏览器的代理配置中某处有 No proxy for localhost, 127.0.0.1 节 - 如果 运行 浏览器和 JMeter 在同一台机器上,请取消勾选或删除它。 "Classic" Firefox 配置应该类似于:

  1. 使用起来可能更容易 JMeter Chrome Extension,在这种情况下,您无需担心代理设置、SSL 证书和相关配置、cookie 等。