Hello, We face a bug in JMeter when : - using proxy - and using POST method which leads to a 404 - The first request leads as expected to a 404 results - BUT (bug is here) the second one triggers a org.apache.http.NoHttpResponseException: jmeter.apache.org:80 failed to respond
Bug id: https://bz.apache.org/bugzilla/show_bug.cgi?id=63015 To reproduce it in Junit below , I just added: - EntityUtils.consumeQuietly(response.getEntity()); This call consumes data and at the end will call ConnHolder#releaseConnection(true). While if missing, ConnHolder#releaseConnection(false) would be called closing the Connection so since we start with a new one, it's ok. In JMeter , since we consume data we end up calling eofWatcher.eofDetected(toCheckStream);which calls ResponseEntityProxy#eofDetected which calls ConnHolder#releaseConnection(true); Find below JUnit: @Test public void bugWithPostAndProxy() throws Exception { PoolingHttpClientConnectionManager pHCCM = new PoolingHttpClientConnectionManager(2000, TimeUnit.MILLISECONDS); pHCCM.setDefaultMaxPerRoute(5); pHCCM.setValidateAfterInactivity(1700); HttpHost proxy = new HttpHost("localhost", 8888, "http"); RequestConfig config = RequestConfig.custom().setProxy(proxy).build(); try (CloseableHttpClient httpclient = HttpClients.custom(). setConnectionManager(pHCCM). setDefaultSocketConfig(SocketConfig.DEFAULT). setConnectionTimeToLive(2000, TimeUnit.MILLISECONDS). setRetryHandler(new StandardHttpRequestRetryHandler(0, false)). setConnectionReuseStrategy(DefaultClientConnectionReuseStrategy.INSTANCE). build()) { HttpHost target = new HttpHost("jmeter.apache.org"); HttpPost request = new HttpPost("/404.html"); request.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); request.addHeader("Connection", "keep-alive"); request.setConfig(config); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(HttpClientContext.USER_TOKEN, "Thread Group1-1"); try (CloseableHttpResponse response = httpclient.execute(target, request, httpContext)) { logger.info("Headers:{}", response.getEntity().toString()); EntityUtils.consumeQuietly(response.getEntity()); logger.info("Headers:{}", response.getAllHeaders()); } request = new HttpPost("/404.html"); request.addHeader("Connection", "keep-alive"); try (CloseableHttpResponse response = httpclient.execute(target, request, httpContext)) { EntityUtils.consumeQuietly(response.getEntity()); logger.info("Headers:{}", response.getEntity().toString()); logger.info("Headers:{}", response.getAllHeaders()); } } } Stacktrace: org.apache.http.NoHttpResponseException: jmeter.apache.org: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:165) 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:185) 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:72) at org.apache.jmeter.protocol.http.proxy.RequestBug.bugWithPostAndProxy(RequestBug.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)