Bug 52396 - TCP Sampler in "reuse connection mode" reuses previous sampler's connection even if it's configured with other host, port, user or password
Summary: TCP Sampler in "reuse connection mode" reuses previous sampler's connection e...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.5.1
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-29 08:08 UTC by sanjiely
Modified: 2011-12-31 10:53 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sanjiely 2011-12-29 08:08:09 UTC
In my test case, I must re-use two TCP connections. For example, firstly I created a TCP connection to the target address 10.0.0.2/554 and select the check box "Re-use connection" for I want to re-use it later; then I created another TCP connection to 10.0.0.2/555 and select the option "Re-use connection" also.
But I found my second data will be sent from the first connection to 10.0.0.2/554, and no new connection to 10.0.0.2/555 is created. Obviously it's not my expected result.

My suggestion:
Adding the judgement about the target IP and Port, if they are different, the first connection should be closed and a new connection should be created even the check-boxes "Re-use connection" in these two Samplers both are chosen. In this way, we can avoid send the data to unexpected target address.

But the better way is to support re-using for multi-connections. And they should be closed when "Re-use connection" is unchecked or the thread exiting. This feature is just what I want now. Thanks.
Comment 1 Philippe Mouawad 2011-12-29 16:45:54 UTC
Date: Thu Dec 29 16:45:11 2011
New Revision: 1225587

URL: http://svn.apache.org/viewvc?rev=1225587&view=rev
Log:
Bug 52396 - TCP Sampler in "reuse connection mode" reuses previous sampler's connection even if it's configured with other host, port, user or password

Modified:
   jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
   jmeter/trunk/xdocs/changes.xml
Comment 2 Philippe Mouawad 2011-12-29 16:46:59 UTC
Fixed in trunk, use nightly build as soon as it's available and report if issue is fixed or not:
https://builds.apache.org/job/JMeter-trunk/lastSuccessfulBuild/artifact/trunk/dist/
Comment 3 sanjiely 2011-12-31 05:56:26 UTC
Hi,
   Thank you for your quick reply.
   I haven't tried the nightly build but read the code, and I find it is able to support multi-connections reused now. But maybe here is a minor issue, from the method "threadFinished":
    public void threadFinished() {
        log.debug("Thread Finished"); //$NON-NLS-1$
        closeSocket();
        if (protocolHandler != null){
            protocolHandler.teardownTest();
        }
   The closeSocket method is called, and it will only remove and close the current TCP connection. The other re-used connections will not be closed. Maybe we need a method like closeAllSockets called by threadFinished to traverse all connections to close them.
   Thanks.
Comment 4 Philippe Mouawad 2011-12-31 10:53:27 UTC
Good point, fixed.
Date: Sat Dec 31 10:52:39 2011
New Revision: 1226061

URL: http://svn.apache.org/viewvc?rev=1226061&view=rev
Log:
Bug 52396 - TCP Sampler in "reuse connection mode" reuses previous sampler's connection even if it's configured with other host, port, user or password

Modified:
   jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java