Reputation: 21
I'm trying to use JMeter to test our login API through WebSocket Sampler
But I can't let it parse my variable
Is this a bug or JSON format problem?
the plugin I choose(sorry about the poor description)
https://github.com/maciejzaleski/JMeter-WebSocketSampler
Upvotes: 0
Views: 688
Reputation: 2078
Try using this plugin: https://bitbucket.org/pjtr/jmeter-websocket-samplers/overview. You can install it using plugin manager found here: https://jmeter-plugins.org/.
I have had no issues constructing JSON with variables in the Websocket request. Something like this would work:
{ "type": "${type}",
"body": {
"key1": "${variable1}",
"key2": "${variable2}"
}}
So I would think it would solve your issue.
Cheers
edit: typos
Upvotes: 1
Reputation: 1259
I'm not sure about your escaped quotes (\") - my expection is that these may not parse as JSON.
My solution to this is to add a BeanShell Sampler before the WebSocket Write e.g.
String s = "CONNECT\n" +
"login:${wsToken}\n" +
"passcode:\n" +
"accept-version:1.1,1.0\n" +
"heart-beat:0,0\n" +
"\n" +
'\0' // note: NULL char at end
;
vars.put("wsData", s);
Then in WebSocket Write Sampler - with DataType = "TEXT" set Request Data to
${wsData}
Upvotes: 1