Home > OS >  Connection refused error when number of threads(users) parameter of JMeter increased
Connection refused error when number of threads(users) parameter of JMeter increased

Time:06-18

Iam trying to do a performance test against my application via JMeter. When i increase the number of threads(users) more than 100 i'm getting these errors. Please help me to fix this.

NB: This was working fine until i increased the no: of threads to 25000.
    Docker container is up and accepting connections(working fine with Postman)
[enter image description here][1]
[enter image description here][2]
[enter image description here][3]

org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:8080 [/127.0.0.1] failed: Connection refused (Connection refused)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$JMeterDefaultHttpClientConnectionOperator.connect(HTTPHC4Impl.java:404)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:935)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:646)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:607)
    at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    ... 19 more


  [1]: https://i.stack.imgur.com/Z6b1h.png
  [2]: https://i.stack.imgur.com/JDWYa.png
  [3]: https://i.stack.imgur.com/4Qtrx.png

CodePudding user response:

It seems like you're basically running a DoS attack against your own server.

  1. Check your server configuration for concurrency (e.g. Tomcat has a 'maxThreads'. Apache might have MPM enabled)
  2. Check if your JMeter test produces reasonable load. Does 1 thread represent 1 user? If so, do those users pause between requests? (Use a random wait in JMeter)

CodePudding user response:

I don't think your "performance test" makes a lot of sense because:

  1. You're running JMeter and the system under test on the same machine, both can be very resource intensive and results won't be reliable due to race conditions
  2. You're running your test in GUI mode, it's for tests development and debugging, when it comes to tests execution you should be running your JMeter tests in command-line non-GUI mode
  3. You're running your tests on a laptop which is not connected to power supply so the power saving mode most likely will cause CPU to throttle
  4. You have a lot of Listeners enabled which don't add any value and just consume resources

Coming back to your question I can think of 2 possible reasons:

  1. You've exceeded the maximum number of open connections on the target webserver, check your backend HTTP server documentation to determine how to increase the number of open connections
  2. You've exceeded the maximum number of open connections on your operating system level, check the current limits and amend according to your test scenario.
  • Related