ws-muse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Antonio (JIRA)" <>
Subject [jira] Commented: (MUSE-91) Better handling of finding the right local ip address
Date Tue, 21 Nov 2006 12:47:10 GMT
    [ ] 
Jose Antonio commented on MUSE-91:

I have this problem too with my current project. I need a service that generates a notification
with and EPR to a service that must be called at some point but when that EPR is generated
it gets the
As the EPR can be modified before sending it, I can use the code above to work aroud this
while a better method to find the local IP is implemented. It's a shame that it's not going
to be resolved for the 2.1 release.

> Better handling of finding the right local ip address
> -----------------------------------------------------
>                 Key: MUSE-91
>                 URL:
>             Project: Muse
>          Issue Type: Improvement
>    Affects Versions: 2.0.0
>            Reporter: Andrew Eberbach
>         Assigned To: Dan Jemiolo
>            Priority: Minor
> An interesting problem surfaced recently. If you want to figure out an EPR (for subscription,
say) you'll need to get the ip address. However, InetAddress.getLocalHost().getHostAddress()
can bind to a local interface and get either a loopback address or a 192.168.X.X address...
this is bad. Here's some code to look for the first non-loopback and non-local address.
> String hostAddress = InetAddress.getLocalHost().getHostAddress();
> Enumeration interfaces =;
> while(interfaces.hasMoreElements()) {
> 	NetworkInterface nextInterface = (NetworkInterface) interfaces.nextElement();
> 	Enumeration addresses = nextInterface.getInetAddresses();
> 	while(addresses.hasMoreElements()) {
> 		InetAddress address = (InetAddress) addresses.nextElement();
> 		if(!address.isLoopbackAddress() && !address.isSiteLocalAddress()) {
> 			hostAddress = address.getHostAddress();
> 			break;
>          	}
>        }
> }

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message