Github user zhangminglei commented on the issue:
https://github.com/apache/flink/pull/5449
Thanks @StephanEwen and @NicoK for the response and that let me know more
about details about this issue.
As refers to the first that return something we can bind to. Yes, As long
as it is not the loopback address and I think it is okay for that. So, What do
you think of if we add a check like the below, at this moment, I do not add a
retry number here. Just give an example for hack this. But this might be cause
an endless loop.
```
// our attempts timed out. use the heuristic fallback
LOG.warn("Could not connect to {}. Selecting a local address
using heuristics.", targetAddress);
InetAddress heuristic =
findAddressUsingStrategy(AddressDetectionState.HEURISTIC, targetAddress, true);
if (heuristic != null) {
while (heuristic.toString().contains("127.0.0.1") ||
heuristic.toString().contains("127.0.1.1")) {
heuristic =
findAddressUsingStrategy(AddressDetectionState.HEURISTIC, targetAddress, true);
}
return heuristic;
}
else {
LOG.warn("Could not find any IPv4 address that is not
loopback or link-local. Using localhost address.");
InetAddress address = InetAddress.getLocalHost();
while (address.toString().contains("127.0.0.1") ||
address.toString().contains("127.0.1.1")) {
address = InetAddress.getLocalHost();
}
return address;
}
```
@StephanEwen As refers the second , I think we can use the following code
to find a stuff to bind to for the test. @NicoK Could you also take a look of
those ? Thanks ~
```
Enumeration<NetworkInterface> nifs =
NetworkInterface.getNetworkInterfaces();
while (nifs.hasMoreElements()) {
NetworkInterface nif = nifs.nextElement();
Enumeration<InetAddress> addresses = nif.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = addresses.nextElement();
if (!(addr.getHostAddress().contains("127.0.0.1") ||
addr.getHostAddress().contains("127.0.1.1"))) {
return addr; // this is the stuff we bind to
}
}
}
}
```
---