我对WebSocket做了一些负载测试,以测量发布者(演示者)和订阅者(参与者)之间的消息延迟。下面是我的测试计划的结构。“Setup”TG是一个setUp线程组,用于确保发布者和订阅者在开始通信之前都连接到WebSocket,以测量延迟。
我有一个JSR223后处理器来缓存发布者和订阅者的连接,这样他们就可以在下面的线程组中获得相同的连接。发布者正确发送了3条消息。但是,我不知道为什么订阅者(ParticipantA)线程组中的读取采样器即使在我将超时时间增加到20s后也没有捕获到任何消息。
以下是用于缓存连接的JSR223后处理器:
def participantAConnection = sampler.threadLocalCachedConnection
props.put('participantAConnection' + ctx.getThreadNum(), participantAConnection.get())
下面是用于恢复参与者线程组中的连接的JSR223预处理器。
def participantAConnection = props.get('participantAConnection' + ctx.getThreadNum())
sampler.threadLocalCachedConnection.set(participantAConnection)
我可以在调试采样器中看到演示者和参与者的缓存连接的属性。
participantAConnection0=eu.luminis.websocket.WebSocketClient@1b510239
presenterConnection0=eu.luminis.websocket.WebSocketClient@755f44c9
调试日志已在下面启用:
2022-07-13 01:06:49,666 DEBUG e.l.j.w.SingleReadWebSocketSampler: I/O Error in sampler 'participantACommandsRead'.
java.net.SocketTimeoutException: Read timed out
at sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:280) ~[?:?]
at sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:306) ~[?:?]
at sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:347) ~[?:?]
at sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:800) ~[?:?]
at java.net.Socket$SocketInputStream.read(Socket.java:966) ~[?:?]
at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478) ~[?:?]
at sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472) ~[?:?]
at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70) ~[?:?]
at sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1455) ~[?:?]
at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:1059) ~[?:?]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:244) ~[?:?]
at java.io.BufferedInputStream.read(BufferedInputStream.java:263) ~[?:?]
at eu.luminis.websocket.Frame.parseFrame(Frame.java:61) ~[jmeter-websocket-samplers-1.2.8.jar:?]
at eu.luminis.websocket.WebSocketClient.receiveFrame(WebSocketClient.java:420) ~[jmeter-websocket-samplers-1.2.8.jar:?]
at eu.luminis.jmeter.wssampler.WebsocketSampler.readFrame(WebsocketSampler.java:306) ~[jmeter-websocket-samplers-1.2.8.jar:?]
at eu.luminis.jmeter.wssampler.SingleReadWebSocketSampler.readFrame(SingleReadWebSocketSampler.java:83) ~[jmeter-websocket-samplers-1.2.8.jar:?]
at eu.luminis.jmeter.wssampler.SingleReadWebSocketSampler.doSample(SingleReadWebSocketSampler.java:71) ~[jmeter-websocket-samplers-1.2.8.jar:?]
at eu.luminis.jmeter.wssampler.WebsocketSampler.sample(WebsocketSampler.java:169) ~[jmeter-websocket-samplers-1.2.8.jar:?]
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.5]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
1条答案
按热度按时间efzxgjgh1#
你的方法似乎是好的,为什么你得到暂停的问题是不同的。
1.尝试将发布者和订阅者采样器放入单个线程组中,看看这是否适合您
1.如果是这样的话,很可能是在某个地方有错误,但是我们不能说明哪里没有看到你的完整测试计划,完整的代码,或者至少有debug logging enabled的(至少)WebSocket采样器的jmeter.log文件。这一行需要添加到 log4j2.xml 文件: