Get a response by specific id OR type for example.
Hi Peter, thank you a lot for the plugin it really helps me and saves a lot of time!
Peter, could you please answer: Is there any possibility to get a response by specific id OR type for example.
STEPs: 1. execute sampler write/read, in my case it has the next view
Request data: {"arguments":[{"$type":"","Data":{"name":"","Action":""}}],"invocationId":"123","type":1}
Response data in my hub will contain 2 messages: {"type":1,"arguments":[{"ResponseId":"fdc71216-5bd2-42c9-9fe8-7966be2013cf"}]}? {"type":3,"invocationId":"123","result":{},"Errors":null}}?
I need to get a message with type 3 OR with invocationId 123
Is there any way to get such a message?
thank you.
Comments (8)
-
repo owner -
thank you for fast response
let me rephrase:when i use write/read sampler - it sends a request and gets the first response after the request was done BUT the response which I receive is not related to my request - it comes from another action.
You could see an example of my request and response in the attached file - in general, i need the 2nd response with “type 3“ AND invocationID 4
https://www.dropbox.com/s/hkrxxnvp1y6auev/ER.jpg?dl=0
-
i think i realize the solution, you suggest to Read continuation frames until needed response will not be meet.
-
repo owner Ah, now i understand the issue.
You should realise that websocket protocol is a duplex channel; both peers can send messages whenever they like. You can use the request-response sampler to easily test such a communication pattern, but it is not like an HTTP request that waits for it response: it is simply sending a request and assumes the first message read from the line is the response to that message. Whether that really is the case totally depends on the interaction pattern your client and server are using and on the fact whether your testplan read all previous messages.
As an example: suppose you have a server that always responds with two messages, e.g.
- client sends message
- server sends first response message
- server sends second response message
- (some time passes)
- client sends message
- server sends first response message
- etc
Now, if the JMeter testplan only reads the message sent in action (2), but “forgets” to read the second (sent in action 3), that later when the test plan intents to read the first response to the second client message, it will first read the second response to the first message (sent in action 3), because this is still in the receive buffer.
Does this explanation help?
Kind regards
Peter
-
thank you, for the response.
but are there any best practices or recommendations from your side:
how to properly wait for the needed response after the request has been sent?now I'm using next:
1 WebSocket request-response sampler
2 regular expression extractor (here I'm take a value for specific key )
3 While Controller (with Condition ${__javaScript("${VALUE_FROM_STEP_2/5}" != "NEEDED_value",)})
4 in while controller → WebSocket single read sampler
5 in while controller → regular expression extractor (here I'm take a value for specific key as in step 2)
-
repo owner Right, that’s how i would do it.
-
thank you. could you please close the ticket
-
repo owner - changed status to closed
Sure ;-). Thanks for your reply.
- Log in to comment
Hi,
Thanks for the feedback, nice to hear the plugin is actually useful for you.
I’m not sure if i understand the question. Do you mean you want to extract part of the response? Normal JMeter mechanisms can be used for that (e.g. Regular Expression Extractor). Or do you mean you want to send different requests depending on some condition? Also in that case you could use standard JMeter mechansims, e.g. use a JMeter property in the request data.
Does this help?
Regards
Peter