jmeter 5.1 压测过程中,发现java.net.SocketException: Socket closed
网上查了好多资料, 都说错误的原因是 未设置连接的超时时间
所以HTTP Request Sampler 的 Advanced 页签下设置:
1、Implementation 选为 HttpClient4
2、Timeouts 中的 Connect 一般设置一个10~60秒的值,表示连接的空闲超时时间,避免由于没收到被压测端的响应回来的 Keep-Alive 的 Header 导致的连接断开
设置完后,再跑一遍场景,发现还是会出现Socket closed现象
so,只能再查
通过下面的链接
https://cwiki.apache.org/confluence/display/jmeter/JMeterSocketClosed?spm=a2c4g.11186623.2.16.41ff41eaJzLjlR
Changing configuration:
If you think this server behavior is OK, then configuration can be changed in two places:
Enabling retry
For HttpClient 4, in user.properties set :
httpclient4.retrycount=1
This will make JMeter retry once. For HttpClient 3, in user.properties set:
httpclient3.retrycount=1
This will make JMeter retry once.
Enabling stale check
For HC4 Implementation:
In user.properties:
hc.parameters.file=hc.parameters
In hc.parameters set:
http.connection.stalecheck$Boolean=true
For HC3 Implementation:
In user.properties:
httpclient.parameters.file=httpclient.parameters
In httpclient.parameters set:
http.connection.stalecheck$Boolean=true
我的版本是5.1
参数
hc.parameters.file=hc.parameters
httpclient4.retrycount=1
都在jmeter.properties,不在user.properties文档中
在hc.parameters 文档中设置:
http.connection.stalecheck$Boolean=true
重启jmeter,搞定