JMeter Script- Connection timed out - jmeter

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.

Related

Jmeter- execution issue-[org.apache.httpHostConnectException: Connect to ... failed Connection refused: connect]

Im trying to execute a scenario in jmeter. While I test from my local system I'm not getting any errors (tested for 1000 users). However, when I execute through a remote desktop connection from my client's network Im getting error even for 2 users/threads.
org.apache.http.conn.HttpHostConnectException: Connect to ---[] failed: Connection refused: 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)
Im unable to understand where Im going wrong. Kindly help with suggestions/fixes.
There is nothing you can "fix" from JMeter side here, the error means that JMeter cannot connect to the system under test at the given port to the given host.
Try to access the endpoint using web browser and if it works - then most probably your "client" is using some form of a proxy server and you need to make JMeter aware of this proxy.
If it doesn't - reach out to your client's network administrator as it might be the case the system you're trying to test is blocked by firewall or something like this.
You can also enable debug logging for JMeter's HTTP Request samplers by adding the next line to log4j2.xml file
<Logger name="org.apache.http" level="debug" />
and after JMeter restart you should see way more information regarding what's going on under the hood in jmeter.log file. Compare the logs from your local machine and remote machine in client's network and report the differences.

JMeter javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake Load testing

I am trying to test my API using Jmeter Load testing and i am encountering this error whenever i tried to test 10 or more concurrent request in 20 seconds or more:
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:436)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384)
at org.apache.jmeter.protocol.http.sampler.hc.LazyLayeredConnectionSocketFactory.connectSocket(LazyLayeredConnectionSocketFactory.java:92)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
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.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1271)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:627)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:551)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:490)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(Unknown Source)
... 27 more
10 concurrent user for 10 seconds is successful but when i up my testing, some request replied the above error and some request had been successful during the testing. I think this is not a code issue anymore. In this regard, May i know what is the problem for this? I am trying to test my API from my workstation(Windows) to Linux Dev server where the API is located and i am curious why only some request replied with this error while some is successful since my API URL uses HTTPS.
If you're getting this SSL peer shut down incorrectly error only under the load most probably it means that your system under test gets overloaded and cannot properly respond/gracefully end the connection.
Check your system under test logs for any suspicious entries
Make sure that the system under test has enough headroom to operate in terms of CPU, RAM, Network, etc, it can be done using JMeter PerfMon Plugin
From JMeter side of things you can:
Make sure to follow JMeter Best Practices
The same as for the system under test - make sure that JMeter doesn't lack underlying operating system resources, if it does - consider running JMeter in distributed mode
You can also add javax.net.debug=all line to system.properties file, this way you will get way more information regarding underlying connections problems in stdout
In addition you can add the next lines to log4j2.xml file, this way you will see more details on network connections level in the jmeter.log file
<Logger name="org.apache.http" level="debug" />
<Logger name="org.apache.http.wire" level="debug"/>

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

POST Call works in Postman, but JMeter throws HTTP NoHttpResponseException error

For a load test I have been preparing different POST calls. First in Postman (since I find it more user friendly), once that succeeded I have been setting up my actual load test in Jmeter. In Postman I consistently get the response I need, but in Jmeter I get the following error:
org.apache.http.NoHttpResponseException: (servername here):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.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: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.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1270) at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:630) at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558) at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) at java.lang.Thread.run(Unknown Source)
So far I have concluded:
The endpoint is identical in Jmeter to the endpoint in Postman
The body is identical in Jmeter to the body in Postman
I have copied the exact same headers from Postman to Jmeter
The thread size is 1, so I find it hard to believe it is something with the server.
Is there something I am missing? What else could I try?
I can think of 2 possible reasons:
The "endpoint" is not fully identical, i.e. there is a protocol/host/port mismatch, in order to make sure that JMeter configuration matches Postman 100% just record request(s) originating from Postman using JMeter's HTTP(S) Test Script Recorder, if you configure Postman to use JMeter as the proxy JMeter will capture the requests and create the relevant HTTP Request sampler(s) and HTTP Header Manager(s)
Your machine is using upstream (corporate?) proxy for connecting to the Internet (or Intranet). It might be the case Postman is configured to respect operating system proxy settings and in JMeter you need to specify the proxy manually, see Using JMeter behind a proxy user manual chapter for more details

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

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.

Resources