jmeter压测-“java.net.SocketException: Socket closed“解决方法
2021/7/23 11:09:01
本文主要是介绍jmeter压测-“java.net.SocketException: Socket closed“解决方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
前提:
今天在做jmeter压测某一个接口时,发现现象:
线程数=100个 循环次数=无限 持续时间30分钟
但是请求到40多个请求的时候 后面的请求的响应结果就出现了报错
报错—成功—又出现报错
中间有一个是成功 剩下后面的都是报错的 CPU也才升到6-7%
分为两个报错:
报错1:
java.net.SocketException: Socket closed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) 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:850) at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:561) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1282) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1271) at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:627) at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:551) at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:490) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257) at java.lang.Thread.run(Unknown Source)
百度得知引起 java.net.SocketException: Socket closed 错误的原因通常是 未设置连接的超时时间。
解决方法:
该问题可以尝试通过以下方法解决。
如果在 HTTP Request Sampler 的 Basic 里勾选了Use KeepAlive,那么建议在 Advanced 页签下:
1、Implementation 选为 HttpClient4
2、Timeouts 中的 Connect 一般设置一个10~60秒的值,表示连接的空闲超时时间,避免由于没收到被压测端的响应回来的 Keep-Alive 的 Header 导致的连接断开
这个值的单位是毫秒:15s*1000=15000s
通过上述方法设置后,再次压测,还是会出现这个错误
再次百度,
https://cwiki.apache.org/confluence/display/jmeter/JMeterSocketClosed?spm=a2c4g.11186623.2.16.41ff41eaJzLjlR
将httpclient4.retrycount=0 改为 =1
参考链接:https://www.cnblogs.com/yiyaxuan/p/12673496.html
这篇关于jmeter压测-“java.net.SocketException: Socket closed“解决方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-12-06使用Microsoft.Extensions.AI在.NET中生成嵌入向量
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#