I’ve an application hosted on nginx , I’m not able to hit that API using JMeter.
Receives below error on JMeter Sampler Result
Thread Name:Thread Group 1-1
Sample Start:2022-07-21 18:39:47 IST
Load time:31316
Connect Time:4
Latency:31316
Size in bytes:151
Sent bytes:118
Headers size in bytes:151
Body size in bytes:0
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):
Response code:502
Response message:Could not relay message upstream
HTTPSampleResult fields:
ContentType:
DataEncoding: null
Response ::
HTTP/1.1 502 Could not relay message upstream
Date: Fri, 22 Jul 2022 03:42:26 GMT
Content-Length: 0
Connection: close
Via: HTTP/1.1 m_proxy_sin
But this API works fine from same Host machine over curl, Postman etc.
When hit via JMeter there are no error information available in the nginx log as well regarding the same.
Ping to the host is works fine, the host is reachable from the test Machine.
System Details::
OS : Windows 10
C:Desktop>java --version
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment OpenLogic-OpenJDK (build 11.0.15+10-adhoc..jdk11u)
OpenJDK 64-Bit Server VM OpenLogic-OpenJDK (build 11.0.15+10-adhoc..jdk11u, mixed mode)
JMeter - 5.5
2022-07-25 16:25:47,348 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2022-07-25 16:25:47,351 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
2022-07-25 16:25:47,354 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
2022-07-25 16:25:47,354 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.
2022-07-25 16:25:47,354 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2022-07-25 16:25:47,354 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false
2022-07-25 16:25:47,354 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2022-07-25 16:25:47,354 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2022-07-25 16:25:47,369 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2022-07-25 16:26:18,057 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
2022-07-25 16:26:18,057 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2022-07-25 16:26:18,057 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2022-07-25 16:26:18,057 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
2
Answers
After setting this variable the issue got resolved
set JVM_ARGS="-Djava.net.preferIPv4Stack=true"
If this API works fine for curl or Postman just record the request from curl or Postman using JMeter’s HTTP(S) Test Script Recorder, it will generate the relevant HTTP Request sampler and HTTP Header Manager in order to send exactly the same request.