JMeter50线程启动10秒内报NoHttpResponseException如何解决
JMeter压测报
NoHttpResponseException: 目标地址:80 failed to respond解决 问题复现特征
- 线程组包含4个API调用,压测启动后仅发出10~15个请求、总执行时长不足20秒就会触发报错
- 报错触发无固定规律,请求失败率波动极大,低时仅5%,高时可达75%~80%
- 手动将请求超时参数设置为100000ms后,问题没有任何改善
- 核心报错栈信息:
org.apache.http.NoHttpResponseException: 10.157.254.115:80 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.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157) 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.execchain.MainClientExec.execute(MainClientExec.java:272) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:939) at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:650) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1301) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1290) at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) at java.lang.Thread.run(Unknown Source)
根因说明
这个报错的本质是JMeter从HTTP连接池取出复用的TCP连接发请求时,该连接已经被目标服务端/中间链路提前关闭了,和请求超时完全无关,所以调大超时参数没有任何作用。
常见触发场景:
- 服务端/负载均衡/防火墙配置的空闲连接回收时间短于JMeter连接池的空闲连接清理周期,连接被对端关闭后JMeter仍在复用
- 短时间并发量超过服务端连接承载上限,服务端连接队列打满,直接丢弃连接不返回任何响应
- JMeter默认关闭失效连接校验,复用连接前不会检查连接是否已经处于半开/关闭状态
解决步骤
按优先级依次操作验证:
- 调整JMeter HTTP客户端配置
- 给线程组添加HTTP请求默认值组件,在基础设置里将
实现选项选为HttpClient4 - 切换到组件的「高级」标签页:
- 勾选
Use stale connection check(失效连接检查),复用连接前会提前校验连接可用性,直接过滤掉已被对端关闭的无效连接 - 将
空闲连接清理间隔设置为500010000ms(即510秒),定期清理连接池内长期闲置的连接,确保连接存活时间短于链路所有节点的空闲连接超时配置
- 勾选
- 打开JMeter安装目录下
bin/user.properties文件,追加以下配置后重启JMeter生效,触发该类连接异常时自动重试,避免直接判定请求失败:httpclient4.retrycount=3 httpclient4.request_sent_retry_enabled=true
- 给线程组添加HTTP请求默认值组件,在基础设置里将
- 校验链路节点配置
- 检查被测服务的Web容器(Nginx/Tomcat/Undertow等)配置,确认最大连接数、TCP backlog队列长度、空闲连接超时参数是否能承载当前压测并发量
- 排查压测链路经过的防火墙、网关、负载均衡设备的连接数限制、会话超时配置,避免中间节点主动截断连接
- 压测策略适配
- 将HTTP请求默认值里的
最大连接数、每路由最大连接数设置为和压测并发线程数一致,减少连接池内长期闲置的连接数量 - 采用阶梯加压模式逐步提升并发,同步观测服务端CPU、内存、TCP连接数指标,确认是否存在服务端资源瓶颈导致的主动丢连接
- 将HTTP请求默认值里的
内容的提问来源于stack exchange,提问作者Tester
相关产品推荐
相关产品推荐

