2
votes

I have a JMeter script doing some websocket request using the "WebSocket Samplers by Peter Doornbosch" plugin (websocket request-response sampler). I use the ping/pong frame filter to automatically respond to pings with pongs while my request-response samplers are sending requests. This works fine as long as I do some actions with the request-response websocket samplers.

Now I want to have a pause in my script (e.g. constant timer) which just waits but STILL ANSWERS THE INCOMING PINGS to keep the websocket connection alive (e.g. for 10 minutes) without doing anything else than answering the pings (no other samplers or requests).

Thank you very much!

2

2 Answers

3
votes

Instead of the constant timer, you could insert a "single read sampler" with a long read timeout (e.g. the 10 minutes you mentioned); select the "optional read" checkbox to avoid the read generates an error on the timeout. Combine this with a "ping/pong frame filter" as you did before; the combination with the "single read sampler" will make the filter do its job.

1
votes

In the JMeter WebSocket Samplers repository you can find samples folder where example test plans live.

enter image description here

With regards to your question itself - go for unsolicited pong.jmx

You might also be interested in Single read sample.jmx

Both examples rely on re-using the existing WebSocket connection and querying for updates periodically in loop. The loop can be implemented using Loop Controller or While Controller, in latter case you can break the loop conditionally.