Jmeter - 如何查看已发送的 HTTP 请求(以便调试错误)

Jmeter - How to see HTTP Request Sent (in order to debug errors)

我有一个包含多个单独的 http 调用(采样器)的 jmeter 测试计划。我在所有调用中都遇到了同样的错误:

0,0,, Non HTTP response code: java.net.MalformedURLException, Non HTTP response message: Illegal character found in host: '/',EntSearchTests 1-1,test,fase,,784,0,1,1,null,0,0,0

这是其中一个查询的 jmx 文件的代表性部分(带有一些混淆):

<stringProp name="HTTPSampler.domain">path.to.resource/myResouce</stringProp>
<stringProp name="HTTPSampler.port">8082</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/rest/status</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>

顺便说一句,我必须 运行 这个无 GUI,所以我 运行 从命令行使用 -LDEBUG 获取尽可能多的数据。但是,在日志文件中的任何地方我都看不到显示组合查询的有用信息(比如 运行 作为 curl 的东西),而是全部都是碎片。

从同一服务器对相同端点的基于 curl 的调用工作正常。我假设我需要调整一些小东西,但不确定会是什么。感谢您的帮助

如果你想在 jmeter 日志文件中看到它 - 将下一行添加到 log4j2.xml 文件:

<Logger name="org.apache.http" level="debug" />

你会得到类似的东西:

更多信息:How to Configure JMeter Logging You can also use a Listener like Simple Data Writer并将其配置为将请求数据保存到文件中。

测试完成后,您将能够使用“查看结果树”侦听器打开文件并检查请求详细信息。