yangyichao-mango commented on issue #2921:
URL:
https://github.com/apache/incubator-dolphinscheduler/issues/2921#issuecomment-640197823
> **Describe the bug**
> problem in `OSUtils::getHost`,
>
> ```java
> try {
> return InetAddress.getLocalHost().getHostAddress();
> } catch (UnknownHostException e) {
> logger.error(e.getMessage(),e);
> }
> return null;
> ```
>
> sometimes `InetAddress.getLocalHost().getHostAddress();` return 127.0.0.1,
sometimes return other address, when using other address sending a heartbeat to
zookeeper, throw `KeeperException$NoNodeException`.
>
> 问题在 `OSUtils::getHost` 这个方法中,
`InetAddress.getLocalHost().getHostAddress(); `这个方法有时候返回的是 127.0.0.1,
但是有时候会返回其他IP. 当以其他IP发送心跳时候就会抛 `KeeperException$NoNodeException`
>
> **To Reproduce**
> i dont kwon how to reproduce, but it really happened on my mac, i just
start application, after a while, application throw
`KeeperException$NoNodeException`. On debug mode, i find problem in
`OSUtils::getHost`
>
> 不太清楚如何在其他电脑上复现, 但确实发生在我的Mac上, 启动应用后过一会就会抛
`KeeperException$NoNodeException`. 在Debug的时候我定位到问题出在 `OSUtils::getHost`
>
> **Which version of Dolphin Scheduler:**
> `<version>1.2.1-SNAPSHOT</version>`
>
> **Context:**
> my hosts file:
>
> ```shell
> ##
> # Host Database
> #
> # localhost is used to configure the loopback interface
> # when the system is booting. Do not change this entry.
> ##
> 127.0.0.1 localhost
> 255.255.255.255 broadcasthost
> ::1 localhost
> # BEGIN section for OpenVPN Client SSL sites
> 127.94.0.1 client.openvpn.net
> # END section for OpenVPN Client SSL sites
> ```
Can you provide the other IP you said?
`InetAddress.getLocalHost().getHostAddress();` actually is not a system
independent reliable method, and it will encounter problems in multi network
environment.
The system will register the worker and master nodes in zk, and if your
network environment change, maybe it will cause the
`KeeperException$NoNodeException`.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]