JMeter中的TCP采样器请求

时间:2014-10-15 12:06:50

标签: jmeter

我有一个充当TCP服务器的java程序,我需要测试它的性能。 编写了一个tcp sampler jmeter请求,我能够正确获取响应数据,但响应代码为500,并且日志中存在错误

TCPClientClassName : TCPClientImpl
Response : 500
Checked "Reuse Connection", "Set No Delay" options

Thread Name: Thread Group 1-1
Sample Start: 2014-10-15 17:33:51 IST
Load time: 514
Latency: 0
Size in bytes: 14
Headers size in bytes: 0
Body size in bytes: 14
Sample Count: 1
Error Count: 1
Response code: 500
Response message: org.apache.jmeter.protocol.tcp.sampler.ReadException: 

日志中的例外

2014/10/15 17:35:14 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
2014/10/15 17:35:14 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2014/10/15 17:35:14 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*) 
2014/10/15 17:35:14 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group 
2014/10/15 17:35:14 INFO  - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Thread Group. 
2014/10/15 17:35:14 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
2014/10/15 17:35:14 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1      perThread 1000.0 delayedStart=false 
2014/10/15 17:35:14 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
2014/10/15 17:35:14 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2014/10/15 17:35:14 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 
2014/10/15 17:35:14 INFO  - jmeter.protocol.tcp.sampler.TCPClientImpl: Using platform default charset:windows- 1252 
2014/10/15 17:35:14 INFO  - jmeter.protocol.tcp.sampler.TCPSampler: Using eolByte=10 
2014/10/15 17:35:15 ERROR - jmeter.protocol.tcp.sampler.TCPSampler:    org.apache.jmeter.protocol.tcp.sampler.ReadException: 
at org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl.read(TCPClientImpl.java:117)
at org.apache.jmeter.protocol.tcp.sampler.TCPSampler.sample(TCPSampler.java:414)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl.read(TCPClientImpl.java:104)
... 4 more

2014/10/15 17:35:15 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-1 
2014/10/15 17:35:15 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2014/10/15 17:35:15 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*) 

1 个答案:

答案 0 :(得分:0)

首先,要检查您的TCP服务器是否确实在运行,请运行:

  

telnet主机:端口

如果仍然失败,则可能是因为JMeter与托管TCP服务器的目标服务器之间没有打开防火墙