gpt4 book ai didi

java - Jmeter:TCP Sampler 错误:500 ReadException:从服务器读取错误,读取的字节数:0

转载 作者:可可西里 更新时间:2023-11-01 02:32:57 27 4
gpt4 key购买 nike

从 Jmeter TCP Sampler 检查 TCP 连接时,出现以下错误:

Response code: 500
Response message: org.apache.jmeter.protocol.tcp.sampler.ReadException: Error reading from server, bytes read: 0

我们尝试更改 EOL、连接和响应超时、重新使用连接和关闭连接设置,但没有成功。

Jmeter TCP 采样器日志:

2018-04-24 12:09:09,740 INFO o.a.j.e.StandardJMeterEngine: Running the test!
2018-04-24 12:09:09,741 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2018-04-24 12:09:09,745 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
2018-04-24 12:09:09,755 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : DS Requests
2018-04-24 12:09:09,756 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group DS Requests.
2018-04-24 12:09:09,764 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2018-04-24 12:09:09,765 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=5 perThread=5000.0 delayedStart=false
2018-04-24 12:09:09,765 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2018-04-24 12:09:09,765 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2018-04-24 12:09:09,766 INFO o.a.j.t.JMeterThread: Thread started: DS Requests 1-1
2018-04-24 12:09:09,767 INFO o.a.j.p.t.s.TCPClientImpl: Using platform default charset:windows-1252
2018-04-24 12:09:09,767 INFO o.a.j.p.t.s.TCPSampler: Using eolByte=10
2018-04-24 12:09:09,787 ERROR o.a.j.p.t.s.TCPSampler:
org.apache.jmeter.protocol.tcp.sampler.ReadException: Error reading from server, bytes read: 0
at org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl.read(TCPClientImpl.java:131) ~[ApacheJMeter_tcp.jar:3.3 r1808647]
at org.apache.jmeter.protocol.tcp.sampler.TCPSampler.sample(TCPSampler.java:403) [ApacheJMeter_tcp.jar:3.3 r1808647]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:498) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:424) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:255) [ApacheJMeter_core.jar:3.3 r1808647]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source) ~[?:1.8.0_144]
at java.net.SocketInputStream.read(Unknown Source) ~[?:1.8.0_144]
at java.net.SocketInputStream.read(Unknown Source) ~[?:1.8.0_144]
at org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl.read(TCPClientImpl.java:114) ~[ApacheJMeter_tcp.jar:3.3 r1808647]
... 5 more
2018-04-24 12:09:09,788 INFO o.a.j.t.JMeterThread: Thread is done: DS Requests 1-1
2018-04-24 12:09:09,788 INFO o.a.j.t.JMeterThread: Thread finished: DS Requests 1-1
2018-04-24 12:09:09,789 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2018-04-24 12:09:09,789 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)

请建议如何解决此问题。

最佳答案

使用 TCP 采样器检查连接不是最好的主意,我建议使用 JSR223 SamplerSocket改为上课:

def sock = new Socket()
def host = "example.com" // change it to your host
def port = 80 // change it to your port
def timeout = 1000 // change it to your timeout (in milliseconds)
sock.setSoTimeout(1000)
sock.connect(new InetSocketAddress(host, port))

if (sock.isConnected()) {
log.info('Connection established')
SampleResult.setSuccessful(true)
}
else {
log.info('Server is not listening')
SampleResult.setSuccessful(false)
}

参见 Apache Groovy - Why and How You Should Use It文章了解有关使用 Groovy 脚本增强 JMeter 测试的更多信息。


在大多数情况下,使用 HTTP Raw Request 会容易得多插件比 TCP 采样器。

关于java - Jmeter:TCP Sampler 错误:500 ReadException:从服务器读取错误,读取的字节数:0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49999049/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com