You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Philippe Mouawad <pm...@apache.org> on 2018/12/18 13:13:43 UTC
Issue with Proxy / keep alive , getting NoHttpResponseException after
a failed request
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)
Re: Issue with Proxy / keep alive , getting NoHttpResponseException
after a failed request
Posted by Philippe Mouawad <ph...@gmail.com>.
Hello Oleg,
Thanks for your help, I confirm it works.
So issue would be in JMeter Recorder.
Thanks
On Tue, Dec 18, 2018 at 2:53 PM Oleg Kalnichevski <ol...@apache.org> wrote:
> On Tue, 2018-12-18 at 14:13 +0100, Philippe Mouawad wrote:
> > 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:
> >
>
> JUnit passes for me. Squid proxy docker image can be found here:
>
>
> https://github.com/apache/httpcomponents-client/tree/master/httpclient5-testing/docker/squid
>
> Oleg
>
> > @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.INSTA
> > NCE).
> > 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(Default
> > HttpResponseParser.java:141)
> > at
> > org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
> > HttpResponseParser.java:56)
> > at
> > org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessagePa
> > rser.java:259)
> > at
> > org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHead
> > er(DefaultBHttpClientConnection.java:163)
> > at
> > org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy
> > .java:165)
> > at
> > org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRe
> > questExecutor.java:273)
> > at
> > org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecu
> > tor.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(InternalHttp
> > Client.java:185)
> > at
> > org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttp
> > Client.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(DelegatingMethodAcces
> > sorImpl.java:43)
> > at java.lang.reflect.Method.invoke(Method.java:498)
> > at
> > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
> > Method.java:50)
> > at
> > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal
> > lable.java:12)
> > at
> > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe
> > thod.java:47)
> > at
> > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMet
> > hod.java:17)
> > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> > at
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> > ner.java:78)
> > at
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> > ner.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(JUnit4
> > TestReference.java:86)
> > at
> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
> > .java:38)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> > eTestRunner.java:459)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> > eTestRunner.java:678)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest
> > Runner.java:382)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
> > tRunner.java:192)
>
>
--
Cordialement.
Philippe Mouawad.
Re: Issue with Proxy / keep alive , getting NoHttpResponseException
after a failed request
Posted by Philippe Mouawad <ph...@gmail.com>.
Hello Oleg,
Thanks for your help, I confirm it works.
So issue would be in JMeter Recorder.
Thanks
On Tue, Dec 18, 2018 at 2:53 PM Oleg Kalnichevski <ol...@apache.org> wrote:
> On Tue, 2018-12-18 at 14:13 +0100, Philippe Mouawad wrote:
> > 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:
> >
>
> JUnit passes for me. Squid proxy docker image can be found here:
>
>
> https://github.com/apache/httpcomponents-client/tree/master/httpclient5-testing/docker/squid
>
> Oleg
>
> > @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.INSTA
> > NCE).
> > 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(Default
> > HttpResponseParser.java:141)
> > at
> > org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
> > HttpResponseParser.java:56)
> > at
> > org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessagePa
> > rser.java:259)
> > at
> > org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHead
> > er(DefaultBHttpClientConnection.java:163)
> > at
> > org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy
> > .java:165)
> > at
> > org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRe
> > questExecutor.java:273)
> > at
> > org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecu
> > tor.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(InternalHttp
> > Client.java:185)
> > at
> > org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttp
> > Client.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(DelegatingMethodAcces
> > sorImpl.java:43)
> > at java.lang.reflect.Method.invoke(Method.java:498)
> > at
> > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
> > Method.java:50)
> > at
> > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal
> > lable.java:12)
> > at
> > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe
> > thod.java:47)
> > at
> > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMet
> > hod.java:17)
> > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> > at
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> > ner.java:78)
> > at
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> > ner.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(JUnit4
> > TestReference.java:86)
> > at
> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
> > .java:38)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> > eTestRunner.java:459)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> > eTestRunner.java:678)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest
> > Runner.java:382)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
> > tRunner.java:192)
>
>
--
Cordialement.
Philippe Mouawad.
Re: Issue with Proxy / keep alive , getting NoHttpResponseException
after a failed request
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2018-12-18 at 14:13 +0100, Philippe Mouawad wrote:
> 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:
>
JUnit passes for me. Squid proxy docker image can be found here:
https://github.com/apache/httpcomponents-client/tree/master/httpclient5-testing/docker/squid
Oleg
> @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.INSTA
> NCE).
> 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(Default
> HttpResponseParser.java:141)
> at
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
> HttpResponseParser.java:56)
> at
> org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessagePa
> rser.java:259)
> at
> org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHead
> er(DefaultBHttpClientConnection.java:163)
> at
> org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy
> .java:165)
> at
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRe
> questExecutor.java:273)
> at
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecu
> tor.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(InternalHttp
> Client.java:185)
> at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttp
> Client.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(DelegatingMethodAcces
> sorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
> Method.java:50)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal
> lable.java:12)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe
> thod.java:47)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMet
> hod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.java:78)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.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(JUnit4
> TestReference.java:86)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
> .java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:459)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:678)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest
> Runner.java:382)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
> tRunner.java:192)
Re: Issue with Proxy / keep alive , getting NoHttpResponseException
after a failed request
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2018-12-18 at 14:13 +0100, Philippe Mouawad wrote:
> 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:
>
JUnit passes for me. Squid proxy docker image can be found here:
https://github.com/apache/httpcomponents-client/tree/master/httpclient5-testing/docker/squid
Oleg
> @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.INSTA
> NCE).
> 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(Default
> HttpResponseParser.java:141)
> at
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
> HttpResponseParser.java:56)
> at
> org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessagePa
> rser.java:259)
> at
> org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHead
> er(DefaultBHttpClientConnection.java:163)
> at
> org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy
> .java:165)
> at
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRe
> questExecutor.java:273)
> at
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecu
> tor.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(InternalHttp
> Client.java:185)
> at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttp
> Client.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(DelegatingMethodAcces
> sorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
> Method.java:50)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal
> lable.java:12)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe
> thod.java:47)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMet
> hod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.java:78)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.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(JUnit4
> TestReference.java:86)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
> .java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:459)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:678)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest
> Runner.java:382)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
> tRunner.java:192)
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org