1

The WebSocket stream in JMeter is executed only for a frame, I am not able to load test continuous stream using the jars available @ https://bitbucket.org/pjtr/jmeter-websocket-samplers

Jmeter WebSocket jmx When I try triggering the WebSocket request via terminal, it streams output/logs. But in case of JMeter the Websocket runs only for a frame.

WSS request with Port 443:

Thanks for answering the query. Please can you clear some of my doubts: I am trying to load test a scenario where the client is continuously listening to WebSocket.

1 Using a jar file I am able to continuously stream the data when I hit the java jar in the terminal. I can see the data flowing

2. Now I try to replicate the scenario in JMeter, the sampler acts like a request/response, where the connection is lost after the response.

3. Now if I set a loop in JMeter, it does not satisfy the purpose of streaming. It will act as multiple requests sent to the same channel.

Also in the attached image link, the checkbox for Streaming Connection is checked, but it acts like request/response.

Is looping the only option for WebSocket streaming?

Thread Name: Thread Group 1-1 Sample Start: 2017-04-27 17:21:40 IST Load time: 1383 Connect Time: 0 Latency: 0 Size in bytes: 1065 Sent bytes:0 Headers size in bytes: 0 Body size in bytes: 1065 Sample Count: 1 Error Count: 0 Data type ("text"|"bin"|""): Response code: 200 Response message:

[Execution Flow] - Opening new connection - Using response message pattern "" - Using disconnect pattern "" - Waiting for the server connection for 60000 MILLISECONDS - WebSocket conection has been opened - Connection established - Waiting for messages for 60000 MILLISECONDS - Received frame #1 (15 bytes); matched response pattern - Received message #2 (15 bytes); matched response pattern - Leaving streaming connection open

[Variables] - Message count: 2

[Problems]

Response headers:

SampleResult fields: ContentType: DataEncoding: UTF-8

1
  • insufficient information, elaborate on your test plan and configuration, please Commented Apr 27, 2017 at 23:01

2 Answers 2

2

(I cannot comment, that would have been more appropriate for the first part)

According to the text in your post, you are using https://bitbucket.org/pjtr/jmeter-websocket-samplers, but the logging you posted is not from that plugin but from Maciej Zaleski's plugin....

I'm not 100% sure what you mean with "load test continuous stream", but if you mean that the server is just pushing frames to the client, that can be tested with the former plugin. Just setup a loop with a "Single read sampler"...

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

7 Comments

Thanks for answering the query. Please can you clear some of my doubts: I am trying to load test a scenario where the client is continuously listening to WebSocket. 1 Using a jar file I am able to continuously stream the data when I hit the java jar in the terminal. I can see the data flowing 2. Now I try to replicate the scenario in JMeter, the sampler acts like a request/response, where the connection is lost after the response. 3. Now if I set a loop in JMeter, it does not satisfy the purpose of streaming. It will act as multiple requests sent to the same channel.
You should not use the request-response sampler, but the "WebSocket Single Read Sampler". It reads one websocket frame, no more, no less (websocket protocol is frame based). So if you put "Single Read Sampler" in a loop, you're effectively only reading frames, so that should match your requirement to read a stream of data...
This sampler does not loose the connection, it keeps it for re-use by the same JMeter thread. Set up the connection with the "WebSocket Open Connection" sampler, before the loop and check the "use existing connection" option in the "Single Read Sampler".
Moreover, from your answer, i guess that you are using the WebSocket Sampler from Maciej Zaleski's plugin; that might cause the confusion. Use the sampler that is (exactly) called: "WebSocket Single Read Sampler". Hth.
Thank you!! I have used the samplers you mentioned and designed the load script as you mentioned. It's working properly, and also thanks for the giving an overview of websocket.
|
-1

Thank you Peter for your responses on this thread. I have a very similar use-case, just wanted to understand one thing:

If I keep a "Single Read Sampler" within a "Loop", is there a possibility of some messages being lost between iterations of the loop OR is there some sort of buffering/streaming that ensures that between iterations messages are not lost and returned in the next "Single Read Sampler" read?

Thank you in advance for your help on this.

Update:

As expected from Peter's comment on this answer, we do see that frames are read from the input stream one after the other without any drops.

However, we observe that:

  1. Different WS read timeout values affect the reads very differently
  2. For a given connection, if we are expected to receive, say 500 messages, sometime in between, a message is not read by the WS (timeout = 7s) even though the server does push it (within 18ms), due to which the final read count comes as 499. It is seen that this behaviour's extremity depends on the read timeout (even though message is pushed within the timeout).

Has this behaviour been observed anytime before and could you think of any explanation on why this might be happening? Any solution/help on this would be of great help, thank you.

PS: I was unable to add this as a comment, so apologies for posting the query here.

2 Comments

Messages are not lost. Each iteration simply reads the next message (websocket frame to be precise) from the stream. WebSocket protocol runs on top of TCP which provides a reliable ordered stream of bytes.
mehul poddar, this does not provide an answer to the question. You can search for similar questions, or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, ask a new question, and include a link to this one to help provide context. See: Ask questions, get answers, no distractions

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.