zoukankan      html  css  js  c++  java
  • JMeter测试出现java.net.SocketException: Permission denied: connect 解决方案

    java.net.SocketException: Permission denied: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:127)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
    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(Thread.java:745)

    启动配置文件路径:{JMeter 主目录}in

    Linux 启动配置文件:jmeter.sh,添加如下启动参数设置:
    export JVM_ARGS="-Djava.net.preferIPv4Stack=true" 

    Winows 启动配置文件:jmeter.bat,添加如下启动参数设置:
    set JVM_ARGS="-Djava.net.preferIPv4Stack=true"

    重新启动 JMeter 运行脚本即可解决之前的报错。

    后记:

    新的问题出现了,是什么导致了其访问接口的时候,偏好了 IPv4 的呢 ????

    正所谓,功夫不负有心人!后经努力,查询 JDK 的 Networking Properties 才得到了最终的答案,如下所示。

    后来查询了一下 JMeter 的用户手册,发现可以通过修改其配置文件,实现在任意系统的移植,而不需要改每个系统对应的启动文件。

    系统配置文件:{JMeter 主目录}insystem.properties,将 java.net.preferIPv4Stack 设置为 true 即可。

  • 相关阅读:
    centos7.7环境下编译安装tengine2.3.2版本
    centos6.9安装python3.6.9独立的virtualenv环境,并且能正确引入ssl
    django在centos生产环境的部署
    django入门8之xadmin引入富文本和excel插件
    jenkins服务器使用python脚本rabbitmqadmin和shell对目标服务器进行管理
    django入门7之django template和xadmin常用技巧
    mysql5.7同步复制报错1060故障处理
    Centos7.6使用yum安装PHP7.2
    django中安全sql注入等
    django入门6引入验证码插件 django-simple-captcha
  • 原文地址:https://www.cnblogs.com/lirongyang/p/14448042.html
Copyright © 2011-2022 走看看