How to handle callback return response in Jmeter - jmeter

In my REST POST/PUT request I will send callback url with additional data
Once backend server responded with success or failure, i will get response to my callback url.
How can see what response in callback url in Jmeter. Based on response I process further

If this is a 3rd-party URL there is no possibility to intercept the request from your backend to this callback URL with JMeter
If you can change the callback URL to an arbitrary value you can use i.e. HTTP Mirror Server as the callback URL, this way your backend will send the request to JMeter instead of the 3rd-party URL so you will be able to get the status and eventually re-send the request to the callback URL so it won't be lost.
If this is not possible you can investigate where the information about the job status is stored, if it can be found in a log file you can use OS Process Sampler or SSH Command sampler to get it, if it's in the database - you can retrieve it using JDBC Test Elements, etc.

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.

jmeter replace subsequent requests with response from initial request

I am thinking of using Jmeter Access Log Sampler to replay tomcat access log or even normal http sampler with a CSV.
What we have in the log is
url1?CallId=1&otherParam=value
url1?CallId=1&otherParam=value&CONTEXT_ID=123435
url1?CallId=1&otherParam=value&CONTEXT_ID=123435&somemoreParam=etc..
url1?CallId=2&otherParam=value
url1?CallId=2&otherParam=value&CONTEXT_ID=67859
When the first request sent to the server without the CONTEXT_ID the server will do a lot of stuff and create a context id for that CallId and return it in the response. Subsequent calls to the server for the same CallId need to have the this same CONTEXT_ID on the URL. Context_IDs from access logs server will not exist in the target server so I can't just use it as is.
Is there a way to capture the response from the initial request for a given CallId and replace CONTEXT_ID for subsequent requests that contains the same callId?
Thanks & regards
voki
Extract it with:
&CONTEXT_ID=([^"]+)
Re-use it:
${YourParamName}
See also http://jmeter.apache.org/usermanual/regular_expressions.html

Handling Callback URLs in JMeter

My REST Service takes in a JMeter HTTP request and one of the parameters in the request is a callback url.
The REST Service uses this callback url to post back a response.
Is there any JMeter Listener I can use to receive the callback i.e. so that the REST Service can send the response back to a JMeter Listener.
And if possible the Listener can then send in another HTTP Request based on the response.
I'm not sure about your question. But I think you want to receive your REST response and make another request to URL in the response...
By that way, you need to "catch" the response by using Regular Expression Extractor, store URL in the response to a JMeter Variable. Then, you create HTTP Request, and put URL in that JMeter Variable into request.

how to use jmeter with ajax request

How to use JMeter with ajax request?
I have a button with is clicked and by using fiddler I can find the session id which is being sent to the server.
What should I do next using the JMeter in order to handle this.
EDIT:
Let's say I have in my hand the header which call the request. The JSESSIONID AJAXREQUEST
and so on where should I put it ?...
I putted it in http header manager name and value.
Jmeter will not execute Javascript embedded in your web page. However AJAX request is also a HTTP request that Jmeter will be able to run as a separate HTTP request and upon getting the response you can have post processors (using XPATH or REGEX) to extract the session id in a Jmeter variable.
Alternatively you can record the Jmeter scripts using Jmeter proxy and then all the HTTP requests will be recorded for you and you will just need to attach a post processor manually.

When using AJAX should you do everything through AJAX or is it OK to use headers too?

I know when you request a page normally it is typically the case that you would use server side session data and set cookies via HTTP headers, but does it work the same when the content is requested via AJAX?
An AJAX request contains the same request/response information as a traditional HTTP request. You can set cookies on the client once the async callback is executed, etc.

Resources