fshutdown / JMeter-WebSocketSampler

JMeter - WebSocket Sampler
Apache License 2.0
312 stars 191 forks source link

Extract out returned data from socket to use in a variable later? #39

Open SamAlexand opened 9 years ago

SamAlexand commented 9 years ago

Hi,

Nice plugin for jMeter! Was able to configure and run very quickly. In the View Results Tree, I can see the ws responses from the server, so I know that it is working.

Question: When the WebSocket Sampler runs, I'd like to parse out a report id value from the returned json . For example, the server side websocket returns this: {"reportId":"12345","status":"COMPLETE"}

Can I use Regular Expression Extractor to parse the response from WebSocket Sampler? I tried it to no avail, but maybe I'm configuring it wrong.

Thanks Sam

SamAlexand commented 9 years ago

Never mind, it was "user error". :-) Regular Expression Extractor works just fine. I wasn't accounting for stupid space in the returned json between the key and the colon and the colon the the value. i;e; my expression was configured to match "key":"value" but the json was actually "key" : "value", so the match would fail. (note the space)

Very pleased. I''m able to watch the websocket for a certain message, parse out a certain value and save into a jMeter variable, then use that variable in subsequent regular ol' REST API requests.

Again, nice tool!