How to get the response time of calls made within an API with Jmeter - jmeter

I'm using J-meter to get response time for an API via HTTP request but this API internally few more api services. Now, i need the response time taken by these internal calls too.
Pls could anyone assist to get this one sorted via J-meter

Below is what I can think of:-
Check on "Follow Redirect" and then use listener like "View Result tree" or "Simple Data Writer" to write the output in an XML format instead of CSV. There you can find the redirected URLs and response time.
But, XML creation will consumer a lot of resource and should be avoided.
Second, use post processor and fetch the response time from the sampler results along with redirected URL and write it in a csv. This requires some coding.

Related

JMeter & socket.io - I can see the message I want, but the socket plugin is not showing what I expect

Here is the socket message I see in the browser debugger console:
More illustrative, perhaps:
I call an API operation that triggers this message over a socket.
What I Tried
To preclude inaccuracies, I started 2 instances of JMeter.
REST API call.
Revised version of the GitHub JMeter example of sockets.io, in which I just call a WebSocket Sampler repeatedly on wss://events.dev.myserver.com:443/socket.io/?EIO=4&transport=websocket.
I kicked off (2).
While that was running, I kicked off (1).
Expected
Eventually, (1) should show me a sampler in the View Results Tree with the message in the screenshot ("42" - GAME_STARTED)
Actual
The only messages I see look like this:
This is really all I want to do: run the appropriate sampler, a sufficient time after making the API call, to get the message.
Update
We succeeded in finding the message using python-socketio:
sio.connect("https://events.dev.server.com", transports='websocket',
headers={'Sec-WebSocket-Extensions: permessage-deflate', 'Sec-Fetch-Dest: websocket',
'Sec-Fetch-Mode: websocket',
'Cookie: ABCSESSIONDEV=NTI3MzkwNWUtMTJmNS00Y2U0LTk1NGUtMjQ2Mzk5OTYxZWE0'})
And here is the output:
Received packet MESSAGE data 2["message","{\"locationId\":110,\"name\":\"GAME_STARTED\",\"payload\":{\"id\":146724,\"boxId\":2002,\"userId\":419,\"createdAt\":\"2022-03-02T14:35:31\",\"lastModifiedAt\":\"2022-03-02T14:35:36.752\",\"completedAt\":\"2022-03-02T14:35:36.621\",\"activationMethod\":\"TAG\",\"nfcTagId\":\"xxxxxx\",\"gameCount\":1,\"app\":false}}"]
I would like to use the websocket plugin to do this in JMeter now.
tried adding Cookie to WebSocket call - only sids, no messages.
tried adding Cookie to an HTTPS request (like the above code) - 400, bad request.
Take a look at other fields of the HTTP Request, in particular HTTP Headers, most probably your JMeter request is missing some essential information.
My expectation is that in order to "start the game" (whatever it means) you need to open the page in the browser, authorize somehow, follow the steps of the protocol upgrade mechanism, etc. to wit exactly mimic what real browser does, all the request sequence which is prior to starting the game.
You might need to correlate dynamic parameters, add HTTP Header Manager, add HTTP Cookie Manager, etc.

performance testing using jmeter cross checking the response with web data does not match

I have a web service URL:
https://app.snapmed.no/landing-page?flow=chat
The response code is 200 and the response body does not contain any valid data to cross-check with the webpage response or data in chrome It is completely dynamic. Now I do not know a enter image description hereway to add response assertion for this type of response. can someone help me?
Actually you don't have to use assertions, as per Reducing resource requirements chapter of JMeter Best Practices
Use as few Assertions as possible
JMeter automatically checks HTTP Response status codes and marks the HTTP Request sampler as failed if response code is 400 or higher.
If you want to add an extra layer of check you can explicitly validate that the page returns the HTTP Status Code 200 as follows:
also as far as I can see the web page always contains Send bilder til hudlege text so you can validate it as well:
More information: How to Use JMeter Assertions in Three Easy Steps

Signalr load testing in JMeter

I'm trying to do JMeter script for an application with Signalr protocol.
I'm able to identify connection-token, bearer-token, connection-id and co relate with request using long polling transport and receive message, but after third polling I could not receive the correct response, i'm getting response but not the expected and full response.
Could you please help me what could be the issue here?
I'm afraid no one will be able to help without seeing at least:
Anticipated response
Actual response
Reference requests sequence from i.e. real browser captured with a sniffer tool like Wireshark or Fiddler
The same as point 3 but for JMeter instead of the real browser.
Basically you need to execute points 3 and 4 and compare the generated network requests - they must be the same apart from the dynamic parameters (tokens, connection-id, etc.). Given requests are the same - you should be getting the same responses.
Another option is using While Controller in order to continue polling unless response matches your expectation.

Response message: Unauthorized in Jmeter

I'm new to using Jmeter tool.
I have recorded my application using blazemeter (v3.1) and then trying to run that .jmx file in Jmeter, however I am running into an authorization issue and the script fails to run.
I have also tried setting my "HTTP Authorization Manager" with username, url, password but it does not help. If anyone can, please guide me on this Issue. Thanks.
As per 4 Things You Should Never Do with Your JMeter Script article:
Don’t run the script exactly as you recorded it
After recording your script, there is still some work to do before you run it. It’s necessary to correlate variables, parameterize and add elements, to faithfully simulate users.
There are too many ways of possible authentication implementation in your application, most probably you need to send some dynamic value along with credentials which can be fetched from the previous request.
Record your test scenario 2 times and compare recorded requests. Be careful as differences might be in response headers and URL, not only in response data. It makes sense to add View Results Tree listener directly to HTTP(S) Test Script Recorder - this way you will be able to see what data is captured by JMeter and amend its configuration so simulated request would look exactly like the request from the real browser.

Save response from certain WEB resources while recording scenario

I need to create scenario for user interaction with single-page WEB application. The application does lots of AJAX calls in order to authenticate user and get user data.
So I created simple scenario with HTTP Test Script Recorder and tried to record my script.
Everything went well, however I noticed that whilst request data is recorder properly, the response data is not recorder at all. I tried to enable Add assertions and Regex matching - but that didn't work as well.
Can you please advice how do I record response texts as well?
View Results Tree under proxy will record request, responses during recording.
This is useful to understand where a dynamic field comes from. This will help your find from which response X you need to extract data to inject in request X+N.
I think you may find this option useful to add in user.properties:
proxy.number.requests=true
This will give a number to each request and corresponding sampler so you will be able to find response for the request.
Once you have done this, you will start adding Post Processors (Regex, CSS/JQuery, XPAth ...) to Sampler X to extract data from its response.
This will create variables you can then use as ${varName} in request X+N.

Resources