我是JMeter的新手,所以要温柔。我有一个简单的测试计划,可以访问登录页面。此时,它甚至没有登录,只是加载页面。问题是在每次运行时,对页面上的一个CSS文件的请求导致:
org.apache.http.NoHttpResponseException: example.com:443 failed to respond
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:286)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257)
at org.apache.jmeter.protocol.http.sampler.hc.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:199)
at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.receiveResponseHeader(MeasuringConnectionManager.java:212)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:697)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:455)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase$ASyncSample.call(HTTPSamplerBase.java:2034)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase$ASyncSample.call(HTTPSamplerBase.java:2002)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
如果我再次运行测试,则所有其他请求都会成功,但这一个文件每次都会失败。
这是请求数据:
GET https://example.com/mysite/style/bootstrap.min.css
GET data:
Cookie Data:
JSESSIONID=0753E35583DE3C882E88BE4C37FCFB47; BIGipServerdemo-tomcat=654354624.51526.0000
Request Headers:
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36
Accept-Language: en-US,en;q=0.9
Accept-Encoding: gzip, deflate, br
Host: example.com
当我在Chrome或Firefox中加载此页面时,所有文件都会加载,包括此CSS文件,没有任何问题。我怎么能修复这个NoHttpResponseException所以这个CSS文件(我假设更多的东西)按预期返回?
答案 0 :(得分:0)
此文件可能位于browser cache中,尝试使用clean session并使用浏览器开发人员工具检查请求,并仔细检查文件是否仍然存在。如果不是 - 这是您的应用程序部署的问题。如果是 - 我只能考虑使用View Results Tree监听器和浏览器开发人员工具或外部嗅探器工具(如Wireshark
来比较JMeter和真实浏览器发送的请求作为一种解决方法,您可以通过将下一行添加到user.properties
文件来禁用检查缺少的嵌入资源
httpsampler.ignore_failed_embedded_resources=true
JMeter重启将需要选择该属性。
答案 1 :(得分:0)
您应该选中HTTP_Request&#39} Retrieve All Embedded Resources from HTML Files
复选框
告诉JMeter解析HTML文件并发送文件中引用的所有图像,Java小程序,JavaScript文件,CSS等的HTTP / HTTPS请求
因此,您不需要为每个CSS(作为浏览器)提出明确请求