Hey there,
we're trying out snowizard and stumbled across some strange behaviour: we're binding our dropwizard server to a certain ip address, and configured this address as listenAddress in the config file.
We were surprised to see that snowizard registered us in the zookeeper client under a different IP address (which exists locally, it was an IP from a virtual box interface).
Digging a bit in the code, we found this in the CuratorAdvertiser:
public synchronized void initListenInfo(final int port) {
try {
final Collection<InetAddress> ips = ServiceInstanceBuilder
.getAllLocalIPs();
if (Iterables.size(ips) > 0) {
listenAddress = String.valueOf(Iterables.get(ips, 0))
.substring(1);
LOGGER.debug("Found Local IP Addresses: {}, using {}", ips,
listenAddress);
}
} catch (final SocketException e) {
LOGGER.error("Error getting local IP addresses", e);
}
if (Strings.isNullOrEmpty(listenAddress)) {
LOGGER.debug("Using listenAddress from configuration file");
listenAddress = configuration.getListenAddress();
}
listenPort = port;
}
That shows that prior using the value from the configuration file, it seems to scan for local interfaces and just picks one of the IPs it found - and only uses the address from the configuration file in case no local IP address can be found (correct me in case I'm wrong here).
In my opinion, the listenAddress defined in the config should have a higher priority, but I realised that this cannot be easily changed, as - because of the 127.0.0.1 default value - it would always be set, hence just swapping the order in initListenInfo (only iterate through network interfaces in case there was no listenAddress defined in the config file) wouldn't work.
Did we understand the concept wrong, or might this be an actual issue? Is there no way to use the address dropwizard binds itself too? (I remember it was difficult / impossible to figure out as the bindHost configuration option gets hidden in a factory).