当前位置:   article > 正文

Socket closed 异常解决方案:如何解决 JMeter 压测中的问题_jmeter socket closed

jmeter socket closed

问题描述

JMeter 压测时会报 java.net.SocketException: Socket closed

  1. java.net.SocketException: Socket closed
  2. at java.net.PlainSocketImpl.socketConnect(Native Method)
  3. at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
  4. at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
  5. at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
  6. at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
  7. at java.net.Socket.connect(Socket.java:589)
  8. at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
  9. at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:542)
  10. at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:414)
  11. at org.apache.jmeter.protocol.http.sampler.LazySchemeSocketFactory.connectSocket(LazySchemeSocketFactory.java:97)
  12. at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
  13. at org.apache.jmeter.protocol.http.sampler.hc.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:318)
  14. at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.open(MeasuringConnectionManager.java:114)
  15. at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
  16. at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
  17. at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
  18. at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
  19. at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:695)
  20. at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:454)
  21. at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
  22. at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1189)
  23. at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1178)
  24. at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:498)
  25. at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:424)
  26. at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:255)
  27. at java.lang.Thread.run(Thread.java:766)

可能原因

引起 java.net.SocketException: Socket closed 错误的原因通常是未设置连接的超时时间。

解决方案

如果在 “HTTP Request Sampler” 的 Basic 里选中了 “Use KeepAlive”

则需要在 Advanced 页签下设置如下参数:

  • 选择 Implementation 为 HttpClient4。
  • Connect 设置一个连接空闲超时时间,避免由于没收到被压测端返回的 Keep-Alive 的Header 而导致连接断开。

最后感谢每一个认真阅读我文章的人,礼尚往来总是要有的,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走:

这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴上万个测试工程师们走过最艰难的路程,希望也能帮助到你! 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/891717
推荐阅读
相关标签
  

闽ICP备14008679号