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

xxls0lw8  于 2023-10-20  发布在  Java
关注(0)|答案(1)|浏览(213)

我运行在我的应用程序的登录页面上的100个用户100 20个用户正在通过其余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)
j91ykkif

j91ykkif1#

我相信你正面临着Connection Reset since JMeter 2.10 ? JMeter wiki页面中描述的问题。如果你完全确定被测应用程序的行为是正确的,并且后端不需要进行任何调整,你可以配置JMeter重试被拒绝的连接并检查陈旧的连接:
1.将所有HTTP请求采样器的“实现”更改为HttpClient4。最简单的方法是使用HTTP Request Defaults配置元素。
1.在JMeter安装的/bin文件夹下的 user.properties 文件中添加以下属性:

httpclient4.retrycount=1
hc.parameters.file=hc.parameters

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

http.connection.stalecheck$Boolean=true

1.重新启动JMeter。
您的“连接重置”问题应该会消失。

相关问题