Bug 40750 - TCPSampler : Behaviour when sockets are closed by remote host
TCPSampler : Behaviour when sockets are closed by remote host
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.2
All All
: P2 normal with 1 vote (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on: 52104
Blocks:
  Show dependency tree
 
Reported: 2006-10-12 17:27 UTC by marc!
Modified: 2011-11-23 22:27 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description marc! 2006-10-12 17:27:09 UTC
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
Comment 1 Trent Bartlem 2009-07-21 23:22:16 UTC
This can be worked around by not reusing TCP connections (this option is available in JMeter 2.3.4 or later)
Comment 2 Philippe Mouawad 2011-10-27 20:51:39 UTC
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 ?
Comment 3 Philippe Mouawad 2011-11-14 12:15:40 UTC
Changes made in trunk > 2.5.1
Decide wether it's enough
Comment 4 Sebb 2011-11-23 22:27:12 UTC
I think that's probably OK for now.

Please re-open if there are additional cases that are not covered by the updated code.