• JMeter压测“java.net.SocketException: Socket closed”解决方法


    报错详情:

    1. java.net.SocketException: Socket closed
    2. at java.net.SocketInputStream.socketRead0(Native Method)
    3. at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
    4. at java.net.SocketInputStream.read(SocketInputStream.java:171)
    5. at java.net.SocketInputStream.read(SocketInputStream.java:141)
    6. at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:161)
    7. at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82)
    8. at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:278)
    9. at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
    10. at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
    11. at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
    12. at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:286)
    13. at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257)
    14. at org.apache.jmeter.protocol.http.sampler.hc.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:199)
    15. at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.receiveResponseHeader(MeasuringConnectionManager.java:212)
    16. at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
    17. at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
    18. at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684)
    19. at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486)
    20. at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
    21. at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    22. at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:697)
    23. at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:455)
    24. at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
    25. at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1189)
    26. at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1178)
    27. at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490)
    28. at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416)
    29. at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250)
    30. at java.lang.Thread.run(Thread.java:748)

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

    解决方法:

    该问题可以尝试通过以下方法解决。

    如果在 HTTP Request Sampler 的 Basic 里勾选了 Use KeepAlive,那么建议在 Advanced 页签下:

    1、Implementation 选为 HttpClient4

    2、Timeouts 中的 Connect 设置一个10~60秒的值,表示连接的空闲超时时间,避免由于没收到被压测端的响应回来的 Keep-Alive 的 Header 导致的连接断开

    参考资料:

    https://help.aliyun.com/knowledge_detail/112842.html

    https://cwiki.apache.org/confluence/display/jmeter/JMeterSocketClosed?spm=a2c4g.11186623.2.16.41ff41eaJzLjlR

    原文链接:http://www.cnblogs.com/ailiailan/p/11519465.html

  • 相关阅读:
    spring下配置shiro
    web.xml文件配置说明
    spring中配置缓存—ehcache
    applicationContext.xml配置简介
    spring task定时器的配置使用
    spring配置数据库连接池druid
    Mybatis使用pageHelper步骤
    mybatis-generator和TKmybatis的结合使用
    PHP删除一个目录下的所有文件,不删除文件夹
    nodejs学习
  • 原文地址:https://www.cnblogs.com/doudouzi/p/12098007.html
Copyright © 2020-2023  润新知