"The target server failed to respond" with default Jmeter's implementation of HTTPSample - jmeter

I have following situation:
there is some Jmeter test. I run it from different locations. I get below error for some requests.
org.apache.http.NoHttpResponseException', 'Non HTTP response message:
The target server failed to respond'
Error is not permanent, it happens from time to time.
The weird thing here is that for some location this error happened and for some not.
Jmeter configuration (jmeter.properties) is identical for all locations, however mentioned error occurred only for some of them.
I've searched regarding that error and find a post about problem with HttpClient4 (which is default for HttpSampler implementation).
When I change implementation to 'Java' - problem gone.
However I can't understand why does the test works from one location and failed from another. Does somebody have any ideas regarding that? The only idea I have is some kind of firewall that has some connections limitation from some specific address.
p.s. All URL that fails where accessible from all locations with the browser, if any.

Read this:
https://wiki.apache.org/jmeter/JMeterSocketClosed
It explains why issue happens with HTTP Client.
Browsers by default do stale check and retries which may explain why you don't reproduce in Browsers.

I was getting the same problem when trying to get a token from WSO2
org.apache.http.NoHttpResponseException: The target server failed to respond
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:95)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:61)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:289)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:191)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:127)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:715)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:520)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:481)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:298)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1105)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1094)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
at java.lang.Thread.run(Unknown Source)
Changing the Protocol to https worked for me.

Related

VSCode WSL-2 Proxy Problem: Failed to establish a socket connection to proxies

Problem Description
When I was using Node.js and generated the file package.jons, I found there's a warning at the start:
Problems loading reference 'https://json.schemastore.org/package': Unable to load schema from 'https://json.schemastore.org/package': Failed to establish a socket connection to proxies: ["SOCKS5 127.0.0.1:1090","SOCKS 127.0.0.1:1090"].
Possible Reason
Then I searched the error message Failed to establish a socket connection to proxies, and found maybe it's a wsl2 proxy problem according to this github reply.
For more precise reason, I searched the VSCode proxy document metioned by the reply, and found maybe it's caused by wrong proxy setting.
Ways to try
According to the VSCode document, I want to try the setting of "Manual proxy address". But I encountered two problems:
I don't know how to run the command line mentioned in the VSCode document: --proxy-server=<scheme>=<uri>[:<port>][;...] | <uri>[:<port>] | "direct://".
I don't know where to find the file /etc/resolv.conf mentioned in the github reply to get the wsl server ip.
When I switch my VPN into global mode and restart VSCode, the warning disappear.

org.apache.http.NoHttpResponseException: [server] failed to respond error after installing Kaspersky

We have installed Kaspersky anti-virus a few days ago, and when we ran our old Jmeter tests, it raises the exception below.
org.apache.http.NoHttpResponseException: target server 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) ...
When we ran some sample requests in Postman, it also raised errors like socket hang-up or connection reset, but after adding Postman to Kaspersky's exception list, the application executed the tests normally.
We tried adding the jmeter.bat and ApacheJmeter.jar file to the exception list, but Jmeter still raised the NoHttpResponseException even with the exact same request we ran with Postman (we used the test-script recording).
Are we missing more files to be added to the exception list?
Any help would be highly appreciated.
Try adding java.exe and javaw.exe to the exception list

Jmeter - Non HTTP response code: org.apache.http.conn.HttpHostConnectException is observed on trying to record a script for 1 user

I am trying to record a login scenario for my application built using Blazor technology through Templates (File > Templates > Recording) for a single user.
I see that few of the initial sampler results are successful and then I see the below error in View Results Tree. Error is constant on trying many times.
Sampler Result
Thread Name:
Sample Start:2021-01-12 09:35:17 GMT
Load time:21037
Connect Time:21037
Latency:0
Size in bytes:2582
Sent bytes:0
Headers size in bytes:0
Body size in bytes:2582
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:Non HTTP response code: org.apache.http.conn.HttpHostConnectException
Response message:Non HTTP response message: Connect to push.services.mozilla.com:443 [push.services.mozilla.com/44.238.116.130] failed: Connection timed out: connect
HTTPSampleResult fields:
ContentType:
DataEncoding: null
Response Data:
org.apache.http.conn.HttpHostConnectException: Connect to push.services.mozilla.com:443 [push.services.mozilla.com/44.238.116.130] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$JMeterDefaultHttpClientConnectionOperator.connect(HTTPHC4Impl.java:401)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
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:930)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:641)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1281)
at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:234)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.base/java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.base/java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.base/java.net.PlainSocketImpl.connect(Unknown Source)
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368)
at org.apache.jmeter.protocol.http.sampler.hc.LazyLayeredConnectionSocketFactory.connectSocket(LazyLayeredConnectionSocketFactory.java:91)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 14 more
In the logs, I see errror in
Line 2: 2021-01-12 09:34:16,562 ERROR f.configuration: DefaultObjectWrapper.incompatibleImprovements was set to the object returned by Configuration.getVersion(). That defeats the purpose of incompatibleImprovements, and makes upgrading FreeMarker a potentially breaking change. Also, this probably won't be allowed starting from 2.4.0. Instead, set incompatibleImprovements to the highest concrete version that's known to be compatible with your application.
Line 3: 2021-01-12 09:34:16,562 ERROR f.configuration: Configuration.incompatibleImprovements was set to the object returned by Configuration.getVersion(). That defeats the purpose of incompatibleImprovements, and makes upgrading FreeMarker a potentially breaking change. Also, this probably won't be allowed starting from 2.4.0. Instead, set incompatibleImprovements to the highest concrete version that's known to be compatible with your application.
Line 72: 2021-01-12 09:37:39,166 WARN o.a.j.p.h.p.Proxy: [53022] Problem with SSL certificate for url for 'incoming.telemetry.mozilla.org'? Ensure browser is set to accept the JMeter proxy cert: Software caused connection abort: recv failed
NOTE :
I have tried recording using the Non HTTP Script Recorder too - same issue.
I see this issue when application is launched on a test server with no internet connection.
I see this issue when the application is hosted locally on the same test server.
Also in UI - Page contents do not load and login page is displayed as a blank page with only the page title and page url as expected.
The application URL is of the format https://abcd.com:1234/login
I have updated the port number in JMeter and Firefox browser as 8888
Root CA certificate is added.
I see the same issue even after increasing timeout to 60000 in HTTP Request defaults
Looking into the push.services.mozilla.com hostname it appears that JMeter catches requests to Firefox Web Push notifications service (allowing websites to send notifications to you)
I don't think you should be recording these requests (unless you're explicitly testing them) so you should add this push.services.mozilla.com to "URL Patterns to Exclude" section of the HTTP(S) Test Script Recorder
More information: Excluding Domains from the Load Test
You should repeat the exercise for all the requests to/from 3rd-party domains if any so your test scope would be limited to your system under test only

JMeter Script- Connection timed out

I am receiving the below error when trying to run a JMeter script . The API works fine in Loadrunner .
I had set the https.default.protocol=TLSv1.2 in user.properties for the SSL version. What could cause the below error .
org.apache.http.conn.HttpHostConnectException: Connect to rXXXXX.XXXX-XXXX.XXXXXX.net:443 [XXXXXX.XXXXXX-XXXXXX.XXXXXX.XXXXXX/21.60.245.182] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$JMeterDefaultHttpClientConnectionOperator.connect(HTTPHC4Impl.java:326)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
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:850)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:561)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1282)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection timed out: connect
e
Given you send the same request you should get the same response no matter what tool is being used for sending the request.
If you're getting different responses or not getting a response either you're sending not the same request or there is a difference in the tools configuration.
The most possible reason could be proxy, by default Loadrunner respects underlying operating system proxy settings and in JMeter you need to configure the upstream proxy connection manually, see Using JMeter behind a proxy article for more details
Another reason could be incorrect request configuration, i.e. protocol/host/port/path mismatch
And last but not the least, maybe your connect/response timeouts are too low, try ramping them up, the relevant setting lives under "Advanced" tab of the HTTP Request sampler (or even better go for HTTP Request Defaults)
Make sure that whatever the endpoint you try to access with this Jmeter script does not expect mutual SSL validation.
Then make sure that your token is generated from CA signed token generator before making the request.
Make sure that your connection timeout is not enough to respond after the request is made and make sure that the timeout is larger than the ramp-up time period.

I am able to run the script with 2 users but not with the multiple users in jmeter

I am able to run the script with 2 users but not with the multiple users in jmeter.
My observations after recording the script for few requests :
Under Workbench - View results tree - Response as
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:928)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
at org.apache.jmeter.protocol.http.proxy.HttpRequestHdr.parse(HttpRequestHdr.java:118)
at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:210)
Sampler result response: Response message:`Connection reset
ensure browser is set to accept the JMeter proxy certificate``
And i have added JmeterROOTCA certificate in Browser.
Could anyone please suggest why this is happening
The error you're getting is connected with recording tests, not executing the tests. Normally you don't need to add certificates especially into browser for the tests execution. If you're not able to record the test follow instructions from the "HTTPS recording and certificates" chapter of the HTTP(S) Test Script Recorder user manual entry. Sometimes clearing your browser history helps
Workbench was removed in JMeter 4.0 so it looks like you're using quite and outdated JMeter version and according to JMeter Best Practices you should always be using the latest one

Resources