最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JMeter WebSocket Plugin - Handling Multiple Responses & ClassCastException - Stack Overflow

programmeradmin2浏览0评论

I am using JMeter with the Peter Doornbosch WebSocket Sampler Plugin to test a WebSocket API. However, I am facing two issues:

Issue 1: ClassCastException Error When running the WebSocket request, I get the following error in the response:

Response message: Sampler error: java.lang.ClassCastException: class eu.luminis.websocket.PingFrame cannot be cast to class eu.luminis.websocket.DataFrame (eu.luminis.websocket.PingFrame and eu.luminis.websocket.DataFrame are in unnamed module of loader .apache.jmeter.DynamicClassLoader @3af49f1c)

Has anyone faced this before?

How can I resolve this error?

Issue 2: Handling Multiple WebSocket Responses

Stack trace:

ERROR - jmeter.protocol.websocket: Sampler error: java.lang.ClassCastException: 
class eu.luminis.websocket.PingFrame cannot be cast to class eu.luminis.websocket.DataFrame 
at .apache.jmeter.protocol.websocket.sampler.WebSocketSampler.sample(WebSocketSampler.java:123)
at .apache.jmeter.threads.JMeterThread.run(JMeterThread.java:260)
at java.lang.Thread.run(Thread.java:834)

Request payload:

{
"Id": ${id}
"Type":"creation"
}

My WebSocket request should return 4 responses, but I am only receiving the first response.

When I try running the WebSocket request again with the same payload, I do not get responses 2, 3, and 4. How can I configure JMeter to capture all responses in a single request? Setup Details:

JMeter Version: [5.6.3] WebSocket Plugin: Peter Doornbosch WebSocket Plugin Protocol: WebSocket WebSocket Server Behavior: Sends multiple responses for a single request

What I Have Tried:

Checked logs for errors. Tried increasing the timeout in the WebSocket sampler.

Experimented with different Response Aggregation settings in the plugin.

Would appreciate any guidance on how to fix the ClassCastException and properly capture multiple WebSocket responses in JMeter.

Thanks in advance!

Capturing Multiple Responses in JMeter WebSocket Plugin

I am using JMeter with the Peter Doornbosch WebSocket Sampler Plugin to test a WebSocket API. However, I am facing two issues:

Issue 1: ClassCastException Error When running the WebSocket request, I get the following error in the response:

Response message: Sampler error: java.lang.ClassCastException: class eu.luminis.websocket.PingFrame cannot be cast to class eu.luminis.websocket.DataFrame (eu.luminis.websocket.PingFrame and eu.luminis.websocket.DataFrame are in unnamed module of loader .apache.jmeter.DynamicClassLoader @3af49f1c)

Has anyone faced this before?

How can I resolve this error?

Issue 2: Handling Multiple WebSocket Responses

Stack trace:

ERROR - jmeter.protocol.websocket: Sampler error: java.lang.ClassCastException: 
class eu.luminis.websocket.PingFrame cannot be cast to class eu.luminis.websocket.DataFrame 
at .apache.jmeter.protocol.websocket.sampler.WebSocketSampler.sample(WebSocketSampler.java:123)
at .apache.jmeter.threads.JMeterThread.run(JMeterThread.java:260)
at java.lang.Thread.run(Thread.java:834)

Request payload:

{
"Id": ${id}
"Type":"creation"
}

My WebSocket request should return 4 responses, but I am only receiving the first response.

When I try running the WebSocket request again with the same payload, I do not get responses 2, 3, and 4. How can I configure JMeter to capture all responses in a single request? Setup Details:

JMeter Version: [5.6.3] WebSocket Plugin: Peter Doornbosch WebSocket Plugin Protocol: WebSocket WebSocket Server Behavior: Sends multiple responses for a single request

What I Have Tried:

Checked logs for errors. Tried increasing the timeout in the WebSocket sampler.

Experimented with different Response Aggregation settings in the plugin.

Would appreciate any guidance on how to fix the ClassCastException and properly capture multiple WebSocket responses in JMeter.

Thanks in advance!

Capturing Multiple Responses in JMeter WebSocket Plugin

Share Improve this question asked Mar 19 at 9:04 prabhakaran prabhaprabhakaran prabha 1
Add a comment  | 

1 Answer 1

Reset to default 0

For multiple messages handling check out "Fragmentation" section of the plugin readme:

Fragmentation

WebSocket messages may be fragmented into several frames. In such cases the first frame is an ordinary text or binary frame, but it will have the final bit cleared. The succeeding frames will be continuation frames (whether they are text or binary is inferred by the first frame) and the last continuation frame will have the final bit set. The plugin supports continuation frames, but as the plugin is frame-oriented, you'll have to read them yourself. In cases where the number of fragments is known beforehand, this is as easy as adding an extra WebSocketReadSampler for each continuation frame you expect. If the number of continuation frames is not known, you need to create a loop to read all the continuation frames. For this purpose, the plugin provides a new JMeter variable called websocket.last_frame_final that indicates whether the last frame read was final. This enables you to write a simple loop with a standard JMeter While Controller; use the expression ${__javaScript(! ${websocket.last_frame_final},)} as condition. With a JMeter If Controller, the condition can be simplified to ! ${websocket.last_frame_final} because that controller automatically interprets the condition as JavaScript. See the sample Read continuation frames.jmx test plan for examples of using the While or the If controller to read continuation frames.

If you are unsure whether continuation frames are sent by your server or how much, switch on debug logging: samplers reading a frame will log whether the received frame is a "normal" single frame, a non-final frame (i.e. 1st fragment), a continuation frame or a final continuation frame (last fragment).

ClassCastException means that you're trying to handle response to a Ping frame as data. If you send a single ping you may get pong on the same connection so make sure to consume it in the ping-pong sampler

More information on WebSockets testing with JMeter: JMeter WebSocket Samplers - A Practical Guide

发布评论

评论列表(0)

  1. 暂无评论