I think this might be jmeter's bug. Here is why:
The exception shows
<httpSample t="1002" s="false" rc="Non HTTP response code:
java.net.ConnectException" rm="Non HTTP response message: Connection
refused: connect" tn="getAllCategoryGroup 1-508" sc="1" ec="1" ng="115"
na="115">
<responseData class="java.lang.String">java.net.ConnectException:
Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown
Source)
at
org.apache.jmeter.protocol.http.sampler.HTTPSampler.sample(HTTPSampler.java:490)
at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1037)
at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1023)
at
org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:346)
at
org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:243)
at java.lang.Thread.run(Unknown Source)
Then I check out the JMeter's code HttpSampler.java at line 490:
for (retry = 0; retry <= MAX_CONN_RETRIES; retry++) {
try {
conn = setupConnection(url, method, res);
// Attempt the connection:
savedConn = conn;
conn.connect(); (======= Line 490 =====)
break;
} catch (BindException e) {
if (retry >= MAX_CONN_RETRIES) {
log.error("Can't connect after "+retry+" retries,
"+e);
throw e;
}
protected HttpURLConnection setupConnection(URL u, String method,
HTTPSampleResult res) throws IOException {
...}
Their SetupConnection just open a HttpURLConnection, here is the exerpt:
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET"); //whatever the http method is
This is the very high level what setupConnection is doing. Usually, (by my
limited java net programming knowledge...), you are ready to get response,
but instead, in the calling method at line 490, it immediately calls
URLConnection.connect (out of that HttpURLConnection instance. It is like
in a short time, you are making two connection out of that socket. After
that logic, then it will eventually pull out the response logic. Why is
that?
I wrote a small program to simulate late, and I also get Connection refused
exception, here is the code:
package com.sezmi.middleware.pcs.core;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpUrlConnectionTest {
public static void main(String[] args) {
int total = 5000;
ConnectionThread[] ts = new ConnectionThread[total];
for (int i=0; i<total;i++) {
ts[i] = new ConnectionThread();
}
for (int i=0; i<total; i++) {
ts[i].start();
}
System.out.println("all threads are done...");
}
public static class ConnectionThread extends Thread {
public void run() {
try {
URL url = new
URL("http://localhost:8080/TestPodCast/TestPodCastServlet?test=testAllCategory");
HttpURLConnection conn =
(HttpURLConnection)url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Connection",
"keep-alive");
conn.connect(); // With this line, I am
getting that Connection
Refused exception. Without this line, the request went ok.
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
Can someone let me know if this is truely the jmeter source problem, please
do explain why the second connect method call is necessary.
Thanks.
Shaoxian Yang
--
View this message in context:
http://www.nabble.com/java.net.BindException-returned-from-http-sampler-tp24716020p24726791.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]