1

I am using "WebSocket Samplers by Peter Doornbosch" plugin

The system will send a heartbeat message to the client every 30 seconds. The client must respond for not disconnect to the system.

I want to do the heartbeat part without pausing the current testing process.

What I tried:

  1. Create a Single read sampler in While timer. It will pause the testing process.
  2. Create two thread groups. The Websocket object (connection ID) cannot be shared between two thread groups.
  3. Tried plugin -- Parallel Controller & Sampler, unfortunately it cannot share the websocket object as well.

Edit: For 2, I want the websocket object can be shared between threads. 1 thread for heartbeat job, 1 thread for doing test. Even I input the same connection ID in the second thread, jmeter still treat it as different object.

2 Answers 2

1

You cannot share a websocket connection between threads. This is by design. The solution for your use case is having a single read sampler with a timeout of 30 seconds, followed by a sampler that responds to the heartbeat. You can use the "optional read" option with the read sampler to avoid it generates an error when no message is read during this 30 second period.

Sign up to request clarification or add additional context in comments.

1 Comment

The single read sample blocks the testing process for 30secs. thats not my desire. but it inspires me how to do a workaround: check the time in each loop, if the current time - prev time > 29 secs, open a single read sample with a timeout for 3 seconds, prev time := current time.
0

The Websocket object (connection ID) cannot be shared between two thread groups.

actually it is possible, as per JMeter Documentation:

Properties are not the same as variables. Variables are local to a thread; properties are common to all threads

so there are 2 options for sharing the data between different threads (even if they're in different thread groups)

  1. Use __setProperty() function to convert JMeter Variable into a JMeter Property in first Thread Group and __P() function to read the value in 2nd Thread Group
  2. If your use case is more complex and you want i.e. to wait until connection ID is available you can consider using Inter-Thread Communication Plugin

1 Comment

I created another thread group and added simple read sampler. I clicked option use existing connection. Then start the testing, the result is Response message: Sampler configured for using existing connection, but there is no connection

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.