dropwizard-discovery icon indicating copy to clipboard operation
dropwizard-discovery copied to clipboard

Add config option to provide IP matcher for CuratorAdvertiser to select correct local IP address

Open stantonk opened this issue 9 years ago • 2 comments

I'm not sure if this is the best way to solve this problem, but if you want to run a service locally and you use a VPN, the logic here:

https://github.com/dropwizard/dropwizard-discovery/blob/2c3f45b9a6612515762b0dcec8590f06aa27bff1/src/main/java/io/dropwizard/discovery/core/CuratorAdvertiser.java#L85

will sometimes pick the wrong local IP if you are connected to a VPN.

17:54:36.566 [main] INFO  i.d.discovery.core.CuratorAdvertiser - Using '192.168.225.102' as listenAddress from found addresses: [/192.168.225.102, /10.0.1.101]

Easiest solution I can think of is do have a config param for dropwizard-discovery to match those addresses returned by ServiceInstanceBuilder.getAllLocalIPs(); against a regex pattern like "^10\.0\.1\.\d+" or something like that.

stantonk avatar Dec 23 '15 00:12 stantonk

You can specify an IP in the configuration. Does that work?

jplock avatar Dec 23 '15 11:12 jplock

@jplock it is a reasonable workaround for now, yes, but then the config can't be checked in and used by multiple developers who want to run integration tests. you'd have to manually modify the config each time you ran the tests on a different machine or on a different day (as IPs are dynamically allocated)

stantonk avatar Dec 23 '15 16:12 stantonk