JMeter - How to handle Longpolling transport method - jmeter

One of the Jmeter requests which I captured contains the 'LongPolling' transport method. So it takes high load time/latency.
I don't want to have this much of high latency in the request.
How can I handle this situation in JMeter. I have already tried 'bzm-Parallel Controller' and it was not success.

You can Insert Parent (Right Click) a Runtime Controller with 1 second, it'll execute your long request, but will wait only 1 second and continue to next requests
Notice that it'll be marked as failed due to java.net.ConnectException
If you want you can add a child JSR223 PostProcessor with the following code to mark it successful
prev.setSuccessful(true);
setSuccessful method can override results status

Related

In Jmeter getting a blank/null response for maximum of the samplers, how can I overcome it?

I have a script in which I have 30 to 40 http samplers and say for sampler number 10 I'm getting like 80% samplers response as blank or null, due to which rest of the samplers below it are also getting impacted as the result of variable not getting extracted in the post processor.
The response time at the 90th% for the 10th sampler is around 25sec.
I want to know is there any thing which I can do in the script to avoid this blank issue or is it something which app server is sending as the result of not able to bear the load.
Will changing the response timeout in the HTTP request default to higher value say 5 Min will resolve the issue?
Please help
Thanks.
You might be interested in Extractor Success Assertion plugin which checks whether the variable(s) declared in the PostProcessor(s) still have(s) default value(s) and if nothing has been extracted - it fails the relevant Sampler.
So you could use any other "Action to be taken after a Sampler error" than Continue in your Thread Group to decide whether you want to start new iteration or stop the thread/test when the response is blank.
Extractor Success Assertion plugin can be installed (and kept up-to-date) using JMeter Plugins Manager

JMeter is Skipping second Get HTTP request in a thread geoup

To the left of the screenshot, I'm executing two 2 HTTP get requests (Same URL) marked in yellow. but as you see in the right side the Get request was executed only once and skipped the second time.
what am I doing wrong here?
Please check this screenshot
JMeter shouldn't "skip" requests, I can think of the following reasons:
You're running the test with more than 1 thread (virtual user) in the Thread Group, if this is the case - the sequential order of requests execution will not be guaranteed, you will need to add __threadNum() function in order to be able to distinguish the responses coming from different virtual users.
An error preventing the request from execution occurred, if this is the case - most probably the reason is in jmeter.log file (you might need to increase JMeter logging verbosity in order to get more information)

JMeter - How to handle Long polling transport request method

In my Jmeter script request which contains the 'LongPolling' transport method and it takes a high load time or response time
Also, the response message content value is used for the next consecutive request. How can I handle that scenario?
I don't want this my wait time for the server response
JMeter thread model assumes that a thread (virtual user) always waits for the previous sampler to fully complete before starting the new one.
The easiest solution is moving your "long-polling" requests into a separate thread group and if you need to pass data between thread groups either use __setProperty() and __P() functions combination or go for Inter-Thread Communication Plugin
If you need to have everything within the single Thread Group - you can consider using Parallel Controller, however it might not be fully suitable for your needs as it is still a Sampler hence it waits for all its children completion prior to proceeding
Depending on your use case you can find jmeter-asynchronous-http plugin useful, see How to Load Test Async Requests with JMeter article for more details if needed.

JMeter - Stop thread after error, but allow retries

I have a JMeter script which makes requests to 5 different endpoints. If there's an error, that thread should be stopped.
However, I would like to retry the request to the 3rd endpoint 3 times before stopping the thread.
Here is what my script looks like:
Thread Group (with Stop thread selected)
HTTP Request (1st endpoint)
HTTP Request (2nd endpoint)
Transaction Controller
While Controller
HTTP Request (3rd endpoint)
JSR223 PostProcessor (to save the response code in a variable for the while controller to check)
Counter (to keep track of the retry count)
JSR223 Assertion (to set the result as successful, so the first failed retries don't count)
HTTP Request (4th endpoint)
HTTP Request (5th endpoint)
Since I checked option Stop thread under Thread Group, if the first request to the 3rd endpoint fails, the thread stops and no retries are made.
If I check Continue, then the retries to the 3rd endpoint work as intended, but the thread doesn't stop if the requests to the other endpoints fail.
I also tried to add the following Groovy script to the JSR223 PostProcessor, but it didn't work:
if (prev.isStopThread()) {
prev.setStopThread(false)
}
I'd appreciate any help I can get.
Thank you!
Just set "Action to be taken after a Sampler error" to Continue in the Thread Group to prevent threads from stopping.
If you decide to stop the thread you can do it in 2 ways:
Via Flow Control Action Sampler (in conjunction with the If Controller)
Via any of your JSR223 Test Elements as
prev.setStopThread(true)
You don't even need a counter, since JMeter 5.0 While Controller exposes current iteration via __jm__While Controller__idx pre-defined variable

Jmeter, delay http request with many extracted urls

i have a issue with to many calls to the server.
I have extracted several urls with the "regex extractor".
In the next step, a "http request" calls these urls by ${extractet-urls}
But all requests after the 8th url gets a error 500 response from the server.
I tried to input several timers between, before and everywhere else, but it hasn't an impact.
So my question is:
how can i delay in this single http request which calls all the extracted urls?
Thanks for your help :)
After the requeat you can add sampler ->Java Request. Then change classname to SleepTest and it'll wait 1 second (configurable)
Add a Constant Timer as a child of the HTTP Request sampler (see Scoping Rules for details) and provide desired delay there (in milliseconds). It will cause the relevant thread to "sleep" for the defined amount of milliseconds before executing the HTTP Request. See A Comprehensive Guide to Using JMeter Timers to learn more about using Timers in JMeter tests.
Another option could be using Test Action sampler to create a delay, it doesn't generate sample result so you won't see it in .jtl results file.
The final approach is depending on what you're trying to achieve and how your test is designed.
Alternatively, you can add a Thread Group and define a ramp up time, then put the request inside this group. The ramp up time takes the startup overload too.

Resources