zhlking opened a new issue #9617:
URL: https://github.com/apache/dubbo/issues/9617
从dubbo 2.7.14在docker swarm中注册到nacos中IP地址出现问题
### Environment
* docker swarm
* Dubbo version: 2.7.14
* Java version: 1.8
* #8679 这个更新后开始出现问题的
docker
swarm环境下从2.7.14版本开始获取的是本地虚拟网桥段的地址,获取的IP地址只能够在宿主机上访问,跨主机是不能访问的。2.7.14版本之前能获取到容器swarm网络的IP。
暂时解决办法,重写了org.apache.dubbo.common.utils.NetUtils类。
修改dubbo/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java
的428-444行,如下:
```
if (result == null) { // If not found, try to get the first one
for (NetworkInterface networkInterface : validNetworkInterfaces)
{
Enumeration<InetAddress> addresses =
networkInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
Optional<InetAddress> addressOp =
toValidAddress(addresses.nextElement());
if (addressOp.isPresent()) {
try {
if (addressOp.get().isReachable(100)) {
return networkInterface;
}
} catch (IOException e) {
// ignore
}
}
}
}
}
```
改为:
```
if (result == null) { // If not found, try to get the first one
for (NetworkInterface networkInterface : validNetworkInterfaces)
{
Enumeration<InetAddress> addresses =
networkInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
Optional<InetAddress> addressOp =
toValidAddress(addresses.nextElement());
if (addressOp.isPresent()) {
try {
if (addressOp.get().isReachable(100)) {
result = networkInterface;
break;
}
} catch (IOException e) {
// ignore
}
}
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]