0
votes

Getting ReadException while using the TCP sampler.

   "Response message: org.apache.jmeter.protocol.tcp.sampler.ReadException: 
    Error reading from server, bytes read: 518"

I am trying to test some responses using TCP sampler and not able to determine the End of line byte value that has to be set.

2019-10-28 10:42:01,014 ERROR o.a.j.p.t.s.TCPSampler: 
org.apache.jmeter.protocol.tcp.sampler.ReadException: Error reading from server, bytes read: 518
    at org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl.read(TCPClientImpl.java:131) ~[ApacheJMeter_tcp.jar:4.0 r1823414]
    at org.apache.jmeter.protocol.tcp.sampler.TCPSampler.sample(TCPSampler.java:402) [ApacheJMeter_tcp.jar:4.0 r1823414]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490) [ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416) [ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) [ApacheJMeter_core.jar:4.0 r1823414]
    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.socketRead(Unknown Source) ~[?:?]
    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:114) ~[ApacheJMeter_tcp.jar:4.0 r1823414]
    ... 5 more

Expected to see the 200 response code with response data from the server.But receiving correct Response data with "

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

as response code and message"

Tried with below settings

Re-use Connection--Yes
Close Connection--Yes
Set No Delay--No
SO_LINGER-Blank
End of Line: 128
1

1 Answers

0
votes

Looking into bytes read: 518 I would expect that you got the response from the TCP server you're testing.

If the server is forcefully closes the connection and you expect this behavior you can just "tell" JMeter to treat the TCP Sampler as successful.

  1. Add Response Assertion as a child of the TCP Sampler which is failing
  2. Configure it as follows:

    • Field to Test: Response Code
    • Tick Ignore Status box
    • Pattern Matching Rules: Equals
    • Patterns to Test: 500

    enter image description here

More information: Response Assertions in JMeter 3.2 - New and Improved