我得到java.net.SocketException:使用Jmeter运行负载测试时连接重置异常

时间:2015-04-22 06:48:38

标签: jmeter performance-testing socketexception

我在我的应用程序的登录页面上运行负载测试100个用户中的100个用户正在通过其余的80个用户我得到以下异常,请帮我修复

java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
    at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:281)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:92)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:61)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
    at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:289)
    at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:191)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:127)
    at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:715)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:520)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:505)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:328)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1141)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1130)
    at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:431)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:258)
    at java.lang.Thread.run(Unknown Source)

1 个答案:

答案 0 :(得分:13)

我相信您正面临Connection Reset since JMeter 2.10 ? JMeter维基页面中描述的问题。如果您完全确定被测试的应用程序的行为是正确的,并且无需在后端进行调整或调整,则可以配置JMeter重试拒绝的连接并检查过时的连接:< / p>

  1. 将所有HTTP请求采样器的“实施”更改为HttpClient4。最简单的方法是使用HTTP Request Defaults配置元素。
  2. 在位于JMeter安装的/ bin文件夹下的 user.properties 文件中添加以下属性:

    httpclient4.retrycount=1
    hc.parameters.file=hc.parameters
    
  3. 将下一行添加到 hc.parameters 文件(相同位置,JMeter的/ bin文件夹)

    http.connection.stalecheck$Boolean=true
    
  4. 重新启动JMeter。
  5. 您的“连接重置”问题应该消失。