1. 问题
JMeter分布式压测时,可能出现如下错误
2021-12-08 09:24:45,935 ERROR o.a.j.s.RemoteTestListenerWrapper: Exception on testEnded on host 172.31.138.107
java.rmi.ConnectException: Connection refused to host: 169.254.77.99; nested exception is:
java.net.ConnectException: Connection timed out (Connection timed out)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) ~[?:1.8.0_191]
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216) ~[?:1.8.0_191]
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202) ~[?:1.8.0_191]
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129) ~[?:1.8.0_191]
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227) ~[?:1.8.0_191]
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179) ~[?:1.8.0_191]
at com.sun.proxy.$Proxy21.testEnded(Unknown Source) ~[?:?]
at org.apache.jmeter.samplers.RemoteTestListenerWrapper.testEnded(RemoteTestListenerWrapper.java:78) [ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:220) [ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:492) [ApacheJMeter_core.jar:5.2.1]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:1.8.0_191]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:1.8.0_191]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_191]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_191]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_191]
at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_191]
at java.net.Socket.connect(Socket.java:538) ~[?:1.8.0_191]
at java.net.Socket.<init>(Socket.java:434) ~[?:1.8.0_191]
at java.net.Socket.<init>(Socket.java:211) ~[?:1.8.0_191]
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40) ~[?:1.8.0_191]
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148) ~[?:1.8.0_191]
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613) ~[?:1.8.0_191]
... 10 more
2. 分析
169.254.77.99,该IP来自何处?
在CMD执行ipconfig /all
,发现此IP来自客户端
当我们安装wireshark,vmware时,会创建虚拟IP,导致客户端出现多IP的情况
同样,除了客户端会出现多IP的情况,执行机也可能出现多IP,那么如何解决呢
3. 方案
多IP时,通信时连接了错误的IP,导致连接失败,所以我们需要明确客户端与执行机的通信IP,通过参数java.rmi.server.hostname
指定
windows和linux执行的脚本文件不一样,所以修改的方式也略有差异
3.1. windows
172.31.130.98
为window本机通信IP
set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom
修改为
set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom -Djava.rmi.server.hostname=172.31.130.98
image.png
3.2. linux
修改文件:bin/jmeter-server
取消注释 RMI_HOST_DEF,指定linux本机通信IP
image.png
网友评论