0
votes

I am using the Jmeter WebSocket Sampler. I have successfully connected to the websocket, and can send a text request. It is a chat bot, and I will be validating it's response.

However, I have observed in Fiddler, the websocket responds to the text request with a short confirmation response before the chat bot's response.

for example, the first response is {"ok":true, "replyto":1151810327491, "type":"ack"} where replyto is a message ID. I don't really need this information.

Only then is the real response sent (as I observed in Fiddler), the one I would actually like to read and put Assertions on.

I have tried Websocket request-response Sampler, Websocket Single Write Sampler (followed by a Single Read Sampler), and I have tried the general Websocket Sampler.

TL;DR: The websocket responses come in "frames", each having a JSON response, my samplers are closing right after the first frame.

1

1 Answers

0
votes

If the server is sending frames you are not interested in, there are two possible solutions.

If you know in advance which frame you want to discard (e.g. the first that is received after sending a message), you can simply use a Single Read Sampler to read the message you want to discard and have a second Single Read Sampler read the "real" message.

If the sequence of messages is not that easy to predict, you can use a Frame Filter to discard the messages for you, so they don't show up in the (Read) Sampler. For example, configure a Text Frame Filter with condition "starts with text" and use the string '{"ok":true, "replyto":' as match value, this will discard all frames that start with that string. If this doesn't work because the message you are interested in start with the same string, you can create more complex conditions, even with regular expressions.