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 主目录}\bin
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 主目录}\bin\system.properties,将 java.net.preferIPv4Stack 设置为 true 即可。
标签:SocketException,java,Permission,http,apache,org,net,jmeter 来源: https://www.cnblogs.com/lirongyang/p/14448042.html