java.net.SocketTimeoutException:使用 BinaryTCPClientImpl 类在 Jmeter 的 TCP Sampler 中读取超时

问题描述

我正在通过 TCP 协议使用 Jmeter 测试一台服务器,我正在使用 BinaryTCPClientImpl 类发送十六进制编码的字符串数据。发送单个请求时它工作正常。但是,当我尝试对多个请求运行测试时,只有第一个请求到达服务器,而下一个请求由于连接重置和 ReadException 而丢失。无法理解为什么在第一次请求后连接被关闭/重置。 有人可以帮我吗?

在 TCP 采样器级别,我在配置下面做了:

TCPCLientClass : BinaryTCPClientImpl 主机 IP : 10.0.127.21 端口:40221 超时:连接 - 20000 毫秒/响应 - 6000 毫秒 重用连接:选中 关闭连接:未选中 设置 NoDelays :未选中 SO_LINGER : 空白 行尾(EOL)字节值:10

添加了选中“忽略状态”的响应断言。

请在下面找到调试日志:

2021-02-02 20:31:17,404 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2021-02-02 20:31:17,404 DEBUG o.a.j.t.TestCompiler: adding controller: org.apache.jmeter.threads.ThreadGroup@35a0adde to sampler config
2021-02-02 20:31:17,404 DEBUG o.a.j.t.TestBeanHelper: Setting shareMode=shareMode.all
2021-02-02 20:31:17,404 DEBUG o.a.j.p.t.s.Tcpsampler: Thread Started
2021-02-02 20:31:17,404 INFO o.a.j.s.FileServer: Stored: E:/apache-jmeter-5.1.1/bin/Auth_PT_Final_Data/Auth_PT_Final_Data/Visa_STAN_RRN_AMT_Ecom.csv
2021-02-02 20:31:17,404 DEBUG o.a.j.t.TestCompiler: Subtracting node,stack size = 2
2021-02-02 20:31:17,stack size = 1
2021-02-02 20:31:17,404 DEBUG o.a.j.s.FileServer: Read:stan,rrn,amt
2021-02-02 20:31:17,404 DEBUG o.a.j.t.TestCompiler: adding controller: org.apache.jmeter.threads.ThreadGroup@1952bd7e to sampler config
2021-02-02 20:31:17,404 DEBUG o.a.j.s.FileServer: Read:000017,f0f0f0f0f0f0f0f0f0f0f1f7,000000001800
2021-02-02 20:31:17,404 DEBUG o.a.j.c.GenericController: Calling next on: class org.apache.jmeter.control.GenericController
2021-02-02 20:31:17,404 INFO o.a.j.p.t.s.Tcpsampler: Using eolByte=10
2021-02-02 20:31:17,404 DEBUG o.a.j.p.t.s.Tcpsampler: org.apache.jmeter.protocol.tcp.sampler.Tcpsampler@558f5291 Created: BinaryTCPClientImpl@1e1e67f1
2021-02-02 20:31:17,404 DEBUG o.a.j.p.t.s.Tcpsampler: Using Protocol Handler: org.apache.jmeter.protocol.tcp.sampler.BinaryTCPClientImpl
2021-02-02 20:31:17,404 DEBUG o.a.j.p.t.s.Tcpsampler: tcp://10.0.127.21:40221   
2021-02-02 20:31:17,435 DEBUG o.a.j.p.t.s.Tcpsampler: Created new connection Socket[addr=/10.0.127.21,port=40221,localport=55422]
2021-02-02 20:31:17,435 DEBUG o.a.j.p.t.s.Tcpsampler: org.apache.jmeter.protocol.tcp.sampler.Tcpsampler@558f5291 Timeout=6000,NoDelay=false
2021-02-02 20:31:17,435 DEBUG o.a.j.t.p.AbstractProperty: Running version,executing function
2021-02-02 20:31:17,435 DEBUG o.a.j.p.t.s.BinaryTCPClientImpl: Wrote: 010f0000160102010f00000078861700000000000000000000000100fefd648108f0e016000000000000000
2021-02-02 20:31:22,405 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-2
2021-02-02 20:31:22,405 DEBUG o.a.j.p.t.s.Tcpsampler: Thread Started
2021-02-02 20:31:22,405 DEBUG o.a.j.s.FileServer: Read:000018,f0f0f0f0f0f0f0f0f0f0f1f8,000000001900
2021-02-02 20:31:22,405 DEBUG o.a.j.c.GenericController: Calling next on: class org.apache.jmeter.control.GenericController
2021-02-02 20:31:22,405 INFO o.a.j.p.t.s.Tcpsampler: Using eolByte=10
2021-02-02 20:31:22,405 DEBUG o.a.j.p.t.s.Tcpsampler: org.apache.jmeter.protocol.tcp.sampler.Tcpsampler@5f0ef347 Created: BinaryTCPClientImpl@561435d6
2021-02-02 20:31:22,405 DEBUG o.a.j.p.t.s.Tcpsampler: Using Protocol Handler: org.apache.jmeter.protocol.tcp.sampler.BinaryTCPClientImpl
2021-02-02 20:31:22,405 DEBUG o.a.j.p.t.s.Tcpsampler: tcp://10.0.127.21:40221   
2021-02-02 20:31:22,421 DEBUG o.a.j.p.t.s.Tcpsampler: Created new connection Socket[addr=/10.0.127.21,localport=55423]
2021-02-02 20:31:22,421 DEBUG o.a.j.p.t.s.Tcpsampler: org.apache.jmeter.protocol.tcp.sampler.Tcpsampler@5f0ef347 Timeout=6000,NoDelay=false
2021-02-02 20:31:22,421 DEBUG o.a.j.t.p.AbstractProperty: Running version,executing function
2021-02-02 20:31:22,421 DEBUG o.a.j.p.t.s.BinaryTCPClientImpl: Wrote: 010f0000160102010f00000078861700000000000000000000000100fefd648108f0e016000000000000000
2021-02-02 20:31:26,123 ERROR o.a.j.p.t.s.Tcpsampler: 
org.apache.jmeter.protocol.tcp.sampler.ReadException: 
    at org.apache.jmeter.protocol.tcp.sampler.BinaryTCPClientImpl.read(BinaryTCPClientImpl.java:152) ~[ApacheJMeter_tcp.jar:5.1.1 r1855137]
    at org.apache.jmeter.protocol.tcp.sampler.Tcpsampler.sample(Tcpsampler.java:402) [ApacheJMeter_tcp.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at java.lang.Thread.run(UnkNown Source) [?:1.8.0_192]
Caused by: java.net.socketTimeoutException: Read timed out
    at java.net.socketInputStream.socketRead0(Native Method) ~[?:1.8.0_192]
    at java.net.socketInputStream.socketRead(UnkNown Source) ~[?:1.8.0_192]
    at java.net.socketInputStream.read(UnkNown Source) ~[?:1.8.0_192]
    at java.net.socketInputStream.read(UnkNown Source) ~[?:1.8.0_192]
    at java.net.socketInputStream.read(UnkNown Source) ~[?:1.8.0_192]
    at org.apache.jmeter.protocol.tcp.sampler.BinaryTCPClientImpl.read(BinaryTCPClientImpl.java:134) ~[ApacheJMeter_tcp.jar:5.1.1 r1855137]
    ... 6 more
2021-02-02 20:31:26,123 DEBUG o.a.j.p.t.s.Tcpsampler: org.apache.jmeter.protocol.tcp.sampler.Tcpsampler@558f5291 Closing connection Socket[addr=/10.0.127.21,localport=55422]
2021-02-02 20:31:26,123 DEBUG o.a.j.a.ResponseAssertion: Test Type Info: contains=false,nottest=false,orTest=false
2021-02-02 20:31:26,123 DEBUG o.a.j.c.GenericController: Calling next on: class org.apache.jmeter.control.GenericController
2021-02-02 20:31:26,123 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
2021-02-02 20:31:26,123 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2021-02-02 20:31:26,123 DEBUG o.a.j.p.t.s.Tcpsampler: Thread Finished
2021-02-02 20:31:26,123 DEBUG o.a.j.t.ThreadGroup: Ending thread Thread Group 1-1
2021-02-02 20:31:26,170 ERROR o.a.j.p.t.s.Tcpsampler: 
org.apache.jmeter.protocol.tcp.sampler.ReadException: 
    at org.apache.jmeter.protocol.tcp.sampler.BinaryTCPClientImpl.read(BinaryTCPClientImpl.java:152) ~[ApacheJMeter_tcp.jar:5.1.1 r1855137]
    at org.apache.jmeter.protocol.tcp.sampler.Tcpsampler.sample(Tcpsampler.java:402) [ApacheJMeter_tcp.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at java.lang.Thread.run(UnkNown Source) [?:1.8.0_192]
Caused by: java.net.socketException: Connection reset
    at java.net.socketInputStream.read(UnkNown Source) ~[?:1.8.0_192]
    at java.net.socketInputStream.read(UnkNown Source) ~[?:1.8.0_192]
    at java.net.socketInputStream.read(UnkNown Source) ~[?:1.8.0_192]
    at org.apache.jmeter.protocol.tcp.sampler.BinaryTCPClientImpl.read(BinaryTCPClientImpl.java:134) ~[ApacheJMeter_tcp.jar:5.1.1 r1855137]
    ... 6 more
2021-02-02 20:31:26,170 DEBUG o.a.j.p.t.s.Tcpsampler: org.apache.jmeter.protocol.tcp.sampler.Tcpsampler@5f0ef347 Closing connection Socket[addr=/10.0.127.21,localport=55423]
2021-02-02 20:31:26,170 DEBUG o.a.j.a.ResponseAssertion: Test Type Info: contains=false,170 DEBUG o.a.j.a.ResponseAssertion: Not checking empty response field in: Visa_Ecom
2021-02-02 20:31:26,170 DEBUG o.a.j.c.GenericController: Calling next on: class org.apache.jmeter.control.GenericController
2021-02-02 20:31:26,170 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-2
2021-02-02 20:31:26,170 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-2
2021-02-02 20:31:26,170 DEBUG o.a.j.p.t.s.Tcpsampler: Thread Finished
2021-02-02 20:31:26,170 DEBUG o.a.j.t.ThreadGroup: Ending thread Thread Group 1-2
2021-02-02 20:31:27,407 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-3
2021-02-02 20:31:27,407 DEBUG o.a.j.p.t.s.Tcpsampler: Thread Started
2021-02-02 20:31:27,407 DEBUG o.a.j.s.FileServer: Read:000019,f0f0f0f0f0f0f0f0f0f0f1f9,000000002000
2021-02-02 20:31:27,407 DEBUG o.a.j.c.GenericController: Calling next on: class org.apache.jmeter.control.GenericController
2021-02-02 20:31:27,407 INFO o.a.j.p.t.s.Tcpsampler: Using eolByte=10
2021-02-02 20:31:27,407 DEBUG o.a.j.p.t.s.Tcpsampler: org.apache.jmeter.protocol.tcp.sampler.Tcpsampler@3b587b4f Created: BinaryTCPClientImpl@3238c2f3
2021-02-02 20:31:27,407 DEBUG o.a.j.p.t.s.Tcpsampler: Using Protocol Handler: org.apache.jmeter.protocol.tcp.sampler.BinaryTCPClientImpl
2021-02-02 20:31:27,407 DEBUG o.a.j.p.t.s.Tcpsampler: tcp://10.0.127.21:40221   
2021-02-02 20:31:28,485 WARN o.a.j.p.t.s.Tcpsampler: Could not create socket for tcp://10.0.127.21:40221
java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[?:1.8.0_192]
    at java.net.DualStackPlainSocketImpl.socketConnect(UnkNown Source) ~[?:1.8.0_192]
    at java.net.AbstractPlainSocketImpl.doConnect(UnkNown Source) ~[?:1.8.0_192]
    at java.net.AbstractPlainSocketImpl.connectToAddress(UnkNown Source) ~[?:1.8.0_192]
    at java.net.AbstractPlainSocketImpl.connect(UnkNown Source) ~[?:1.8.0_192]
    at java.net.PlainSocketImpl.connect(UnkNown Source) ~[?:1.8.0_192]
    at java.net.socksSocketImpl.connect(UnkNown Source) ~[?:1.8.0_192]
    at java.net.socket.connect(UnkNown Source) ~[?:1.8.0_192]
    at org.apache.jmeter.protocol.tcp.sampler.Tcpsampler.getSocket(Tcpsampler.java:168) 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...