Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The static worker node obtained the IP address 127.0.0.1 #305

Closed
mycxu opened this issue Oct 17, 2024 · 4 comments
Closed

The static worker node obtained the IP address 127.0.0.1 #305

mycxu opened this issue Oct 17, 2024 · 4 comments

Comments

@mycxu
Copy link
Contributor

mycxu commented Oct 17, 2024

I am attempting to deploy a static cluster, and when I start the static worker node, I noticed that the IP address saved in the static_workers table is 127.0.0.1.
I noticed that in the CurrentStaticWorker.java,the IP address of the static worker node is obtained using the following method:

InetAddress localHost = InetAddress.getLocalHost(); 
String hostAddress = localHost.getHostAddress();

However, this does not seem to be a reliable, system-independent method.It attempts to obtain the local IP address by resolving the hostname, and in most cases, the hostname is set to localhost.
I was able to obtain the correct IP address by using the NetworkInterface class. Would it be a better approach to change my system configuration so that localHost.getHostAddress() returns the correct IP address?

@D-D-H
Copy link
Contributor

D-D-H commented Oct 18, 2024

Would it be a better approach to change my system configuration so that localHost.getHostAddress() returns the correct IP address?

Yes. Would you like to submit a PR for this problem?

@mycxu
Copy link
Contributor Author

mycxu commented Oct 21, 2024

Would you like to submit a PR for this problem?

If we choose to modify the system configuration, we just need to ensure that the "hostname" in /etc/hosts resolves to the IP address we want, so this does not involve any code changes. However, I saw that JCS also encountered this issue and similarly addressed it by using NetworkInterface to obtain the correct IP address.
It is considered that using NetworkInterface might be a more appropriate method. Do you think we need to modify the code to resolve this problem? If so, I can submit a PR.

@D-D-H
Copy link
Contributor

D-D-H commented Oct 21, 2024

Yes, let's use NetworkInterface instead.

We need to consider how to process if multiple addresses are available.

@mycxu
Copy link
Contributor Author

mycxu commented Oct 21, 2024

PR: #306

@D-D-H D-D-H closed this as completed Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants