Problem: ------- When the socket connection used by TCPSampler is closed by the host, the socket will time out, but leave the connection in a "viable" state. Jmeter does not attempt to check for this. If the Thread Group is looped, the same connection will be reused. But it is closed from the host end so all the threads will just time out! As a quick fix for myself, I modified TCPSampler.java. I changed getSocket() to always attempt to close any Sockets already in the cp map, and then create a new one. Suggestions: ----------- As suggested by sebb, if there is no way of automatically detecting and resetting the connection, an option might be used to determine the behaviour if a timeout occurs. This is probably the way to go since we cannot predict the behaviour of every protocol??? THe Jmeter.log is below with TCPSampler debugging on. The actualy data sent and recieved has been removed (just in case). Relevant jmeter.log: ------------------- 2006/10/13 10:17:34 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: Created org.apache.jmeter.protocol.tcp.sampler.TCPSampler@1741064 2006/10/13 10:17:34 INFO - jmeter.protocol.tcp.sampler.TCPClientImpl: Using eolByte=0 2006/10/13 10:17:34 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: org.apache.jmeter.protocol.tcp.sampler.TCPSampler@1741064Created: TCPClientImpl@e05280 2006/10/13 10:17:34 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: Using Protocol Handler: org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl 2006/10/13 10:17:34 INFO - jmeter.engine.StandardJMeterEngine: Running the test! 2006/10/13 10:17:34 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(true,local) 2006/10/13 10:17:35 INFO - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Thread Group. Ramp up = 1. 2006/10/13 10:17:35 INFO - jmeter.engine.StandardJMeterEngine: Continue on error 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: Created org.apache.jmeter.protocol.tcp.sampler.TCPSampler@36f7e6 2006/10/13 10:17:35 INFO - jmeter.protocol.tcp.sampler.TCPClientImpl: Using eolByte=0 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: org.apache.jmeter.protocol.tcp.sampler.TCPSampler@36f7e6Created: TCPClientImpl@cd3bec 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: Using Protocol Handler: org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl 2006/10/13 10:17:35 INFO - jmeter.threads.JMeterThread: Thread Thread Group 1-1 started 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: Thread Started 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: tcp://10.1.1.198:8081 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: org.apache.jmeter.protocol.tcp.sampler.TCPSampler@36f7e6 Timeout 0 NoDelay false 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: Created new connection Socket[addr=addr/10.1.1.198,port=8081,localport=36474] 2006/10/13 10:17:35 DEBUG - jmeter.protocol.tcp.sampler.TCPClientImpl: Wrote: <my_data> 2006/10/13 10:17:36 DEBUG - jmeter.protocol.tcp.sampler.TCPClientImpl: Read: 169 <my_recieved_message> 2006/10/13 10:17:36 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: tcp://10.1.1.198:8081 2006/10/13 10:17:36 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: org.apache.jmeter.protocol.tcp.sampler.TCPSampler@36f7e6 Reusing connection Socket[addr=addr/10.1.1.198,port=8081,localport=36474] 2006/10/13 10:17:36 DEBUG - jmeter.protocol.tcp.sampler.TCPClientImpl: Wrote: <my_data> 2006/10/13 10:17:36 DEBUG - jmeter.protocol.tcp.sampler.TCPClientImpl: Read: 0 2006/10/13 10:17:36 INFO - jmeter.threads.JMeterThread: Thread Thread Group 1-1 is done 2006/10/13 10:17:36 INFO - jmeter.engine.StandardJMeterEngine: Ending thread 0 2006/10/13 10:17:36 INFO - jmeter.engine.StandardJMeterEngine: Stopping test 2006/10/13 10:17:36 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: Thread Finished 2006/10/13 10:17:36 DEBUG - jmeter.protocol.tcp.sampler.TCPSampler: org.apache.jmeter.protocol.tcp.sampler.TCPSampler@36f7e6 Closing connection Socket[addr=addr/10.1.1.198,port=8081,localport=36474] 2006/10/13 10:17:36 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 2006/10/13 10:17:36 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,local) 2006/10/13 10:17:36 INFO - jmeter.engine.StandardJMeterEngine: Test has ended
This can be worked around by not reusing TCP connections (this option is available in JMeter 2.3.4 or later)
With fix of 52104 behaviour is better if timeout is set, connection will be reestablished after: - 1 timeout - 1 broken pipe Can we do better ?
Changes made in trunk > 2.5.1 Decide wether it's enough
I think that's probably OK for now. Please re-open if there are additional cases that are not covered by the updated code.
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1807