JMeter-WebSocketSampler icon indicating copy to clipboard operation
JMeter-WebSocketSampler copied to clipboard

Question: How does responses works?

Open gen4sp opened this issue 11 years ago • 7 comments

i have workflow: several queries one by one. Once i got responce from 1st query, i want fire next one. So i try to play with "response" section and with no success (

so my 1st request:

{
"command":"auth",
"udid":"${udid}"
}

and i got response:

{"response":"auth","data":{"player":{"__v":0,"nick":"Player_58423","_id":"52f4a76a7f83343908e93a30","invites_sent":[],"invites_recived":[],"blackList":[],"friends":[],"games":[],"play_units":10,"rating":1000,"date_created":"2014-02-07T09:29:14.577Z","lang":"ru","udid":["pseudo_udid_489405"]},"is_new":true}}
  1. How does pattern looks? so i expect, the pattern i looking for is "auth" - should works great, right?
  2. how response section (i read the documentation, but still dont get it) what i should to do - place this pattern to 1st sampler, or 2nd, or maybe both?
  3. now i waiting trigger from server, which came after random time, like this
{"response":"opponentFound",
"_id":"XXXX"}

and i going to answer him "ok, i take this opponent" how? Should i create 3th sampler with big response-timeout and place "opponentFound" in response-section, and then create 4th sampler with answer-request, right?

gen4sp avatar Feb 07 '14 09:02 gen4sp

You are right your approach should work

  1. Response pattern is a regular expression but in you case you could just use this:
"response":"auth"
  1. This is sequantial workflow so the same sampler which sends a authenticationrequest should capture a auth response
  2. Take opponent would be a second sampler; you can set a long response timeout and let the sampler wait for a server response. The response pattern could look like this
"response":"opponentFound"

...and 3rd sampler will respond to opponentFound.

And thanks for sharing your problems, I will keep this in mind when developing the plugin further.

fshutdown avatar Feb 07 '14 10:02 fshutdown

Great, thank you for your (quite fast!) answer!

gen4sp avatar Feb 07 '14 10:02 gen4sp

Response doesnt work for me ( 1st sampler: http://take.ms/JCROS answer - http://take.ms/1K3Lb finding works fine, but sampler wait whole response time before fire next sampler, does not fire immediately on response as i expect.

gen4sp avatar Feb 07 '14 10:02 gen4sp

Have a look at the View Results Tree -> Sampler Result there should be a detaild breakdown of all actions and how long did it take for the response to arrive.

fshutdown avatar Feb 07 '14 13:02 fshutdown

response from the server come immediately, but sampler took all 5sec (or more, depends on response-timeout-section) looks like it doesn't recognise the pattern.

Now i have one more strange behavior! If i have some samplers, and set in 1st response-pattern this:

"response"

and leave other blank (!), all samplers fired immediately as recived a response from server.

Whats going on?)

gen4sp avatar Feb 07 '14 13:02 gen4sp

same behaviour when i leave first sampler blank

gen4sp avatar Feb 07 '14 14:02 gen4sp

Could be something to do with regular expression processing. Maybe escaping special characters with \ would help

fshutdown avatar Feb 07 '14 15:02 fshutdown