Bug 50977 - Unable to set TCP Sampler for individual samples
Unable to set TCP Sampler for individual samples
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.4
PC All
: P2 normal (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-03-26 12:49 UTC by Paul Offord
Modified: 2011-03-28 18:26 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Offord 2011-03-26 12:49:49 UTC
OVERVIEW

Whichever TCP Sampler Timeout value comes first in the Test Plan is enforced for all samples despite setting differing values for later TCP Samplers.

STEPS TO REPRODUCE

1. Create a Test Plan with a single thread, Loop Count of 1 and two TCP Samplers.
2. Set the IP Address and TCP Port in both TCP Samplers to point at a server (say TELNET)
3. Put nothing in the Text to send box
4. Set a Timeout in the first TCP Sampler to 1000ms and the second 3000ms
5. Add View Results in Table listener
6. Run the test
7. Review the Sample Time(ms) values in the listener

ACTUAL RESULTS

Both sampler timeout in 1000ms

EXPECTED RESULTS

The second sampler should timeout in 3000ms

BUILD PLATFORM

Windows 7 Professional - 32 bit
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
JMeter 2.4 1 

ADDITIONAL INFORMATION

The cause appears to be in TCPSampler.java and due to the fact that the read timeout is set is on creating the socket only.

Further details can be found at http://jmeter.512774.n5.nabble.com/TCPSampler-Timeout-Can-t-set-on-sample-basis-td3890878.html
Comment 1 Paul Offord 2011-03-26 12:55:54 UTC
I fixed the problem by adding a single line of code to TCPSampler.java as follows:

    public SampleResult sample(Entry e)// Entry tends to be ignored ...
    {
.
.
.
            } else {
                InputStream is = sock.getInputStream();
                OutputStream os = sock.getOutputStream();
               
                // *** FIXED BY ADDING THE FOLLOWING LINE
                sock.setSoTimeout(getTimeout());
               
                String req = getRequestData();
                // TODO handle filenames
                res.setSamplerData(req);
                protocolHandler.write(os, req);
                String in = protocolHandler.read(is);
                res.setResponseData(in, null);
                res.setDataType(SampleResult.TEXT);
                res.setResponseCodeOK();
                res.setResponseMessage("OK"); //$NON-NLS-1$
                isSuccessful = true;
.
.
.

This seems to fix the problem and I'm not getting any adverse effects.

Soory this isn't written like a patch but I don't know how to do it
Comment 2 Milamber 2011-03-28 18:26:53 UTC
Thanks. Finally, I've put the setSoTimeout() in getSocket() because this place is better for do this. I've also sets Nodelay option for each sampler.

URL: http://svn.apache.org/viewvc?rev=1086424&view=rev
Log:
Bug 50977 - Unable to set TCP Sampler for individual samples

Modified:
    jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
    jakarta/jmeter/trunk/xdocs/changes.xml