简体   繁体   中英

Jmeter not sending http request properly

In the view results tree, I cannot see any http request made. Instead it only shows null under request body. Testing with postman works and running jmeter with maven command also works. Running Jmeter pointing to my local server also works. On my colleagues computer also fine.

But if I made http request to remote server using my computer, it only shows null request.

screenshot to remote server

screenshot to my localhost

2019-08-05 14:50:13,951 INFO o.a.j.e.StandardJMeterEngine: Running the test!
2019-08-05 14:50:13,952 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2019-08-05 14:50:13,953 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
2019-08-05 14:50:13,956 INFO o.a.j.e.StandardJMeterEngine: Starting setUp thread groups
2019-08-05 14:50:13,957 INFO o.a.j.e.StandardJMeterEngine: Starting setUp ThreadGroup: 1 : 100 - buildings-login 
2019-08-05 14:50:13,957 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group 100 - buildings-login.
2019-08-05 14:50:13,957 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2019-08-05 14:50:13,957 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false
2019-08-05 14:50:13,959 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2019-08-05 14:50:13,959 INFO o.a.j.e.StandardJMeterEngine: Waiting for all setup thread groups to exit
2019-08-05 14:50:13,959 INFO o.a.j.t.JMeterThread: Thread started: 100 - buildings-login 1-1
2019-08-05 14:50:13,959 INFO o.a.j.s.FileServer: Stored: buildings-enos-wrapper-config-wrapper-parameter.csv
2019-08-05 14:50:13,959 INFO o.a.j.s.FileServer: Stored: buildings-enos-wrapper-config-server-parameter.csv
2019-08-05 14:50:13,959 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``${access_token};'' : Attempt to access property on undefined variable or class name
2019-08-05 14:50:13,959 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval  Sourced file: inline evaluation of: ``${access_token};'' : Attempt to access property on undefined variable or class name
2019-08-05 14:50:13,959 INFO o.a.j.t.JMeterThread: Thread is done: 100 - buildings-login 1-1
2019-08-05 14:50:13,959 INFO o.a.j.t.JMeterThread: Thread finished: 100 - buildings-login 1-1
2019-08-05 14:50:13,959 INFO o.a.j.e.StandardJMeterEngine: All Setup Threads have ended
2019-08-05 14:50:14,037 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : 200 - buildings-wrapper
2019-08-05 14:50:14,037 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group 200 - buildings-wrapper.
2019-08-05 14:50:14,037 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2019-08-05 14:50:14,037 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false
2019-08-05 14:50:14,037 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2019-08-05 14:50:14,037 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2019-08-05 14:50:14,037 INFO o.a.j.t.JMeterThread: Thread started: 200 - buildings-wrapper 1-1
2019-08-05 14:50:14,068 INFO o.a.j.t.JMeterThread: Thread is done: 200 - buildings-wrapper 1-1
2019-08-05 14:50:14,068 INFO o.a.j.t.JMeterThread: Thread finished: 200 - buildings-wrapper 1-1
2019-08-05 14:50:14,068 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2019-08-05 14:50:14,068 INFO o.a.j.s.FileServer: Close: buildings-enos-wrapper-config-server-parameter.csv
2019-08-05 14:50:14,068 INFO o.a.j.s.FileServer: Close: buildings-enos-wrapper-config-wrapper-parameter.csv
2019-08-05 14:50:14,068 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)

Same issue happened to me last week. I resolved it by removing any forward slashes from the "Server Name or IP" field and moving them to the "Path" field. So if you have "www.example.com/foo/" as the server name, you will need to move the "/foo/" part to the Path instead.

you are creating Invalid HTTP Request, sending empty Request Body for a Post Request

go through with this link, for Correct HTTP Request using JMeter

https://www.testingexcellence.com/jmeter-tutorial-testing-rest-web-services/

JMeter tests failed with null requests when openjdk 8 release installed in ubuntu machine. It seems latest update in openjdk on 31th of July in 2019 broke the jmeter functionality for using / in ip field. I wanted to go back older version of openjdk 8 but it is not possible so I installed openjdk 11.0.2 release (earlier version of 11.0.4) then forward my test sets work which have urls with slashes in the "Server Name or IP" field. https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz .

I opened issue for this to apache coomunity: https://bz.apache.org/bugzilla/show_bug.cgi?id=63637

Looking into these lines:

2019-08-05 14:50:13,959 ERROR oajuBeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ${access_token};'' : Attempt to access property on undefined variable or class name 2019-08-05 14:50:13,959 WARN oajeBeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ${access_token};'' : Attempt to access property on undefined variable or class name

It appears that your Beanshell test element is not working properly, if you're building your request programatically - take a closer look at Beanshell script and fix it.

Going forward:

  1. Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting
  2. Don't inline JMeter Functions or Variables into scripts , go for code-based equivalents instead. For example you should change your ${access_token} to vars.get("access_token") where vars is a shorthand for JMeterVariables class instance. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on JMeter API shorthands available in JSR223 Test Elements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM