Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues
Bug 1023 - Use the computers local host address as 'preferred' (first) IORs address
Summary: Use the computers local host address as 'preferred' (first) IORs address
Status: RESOLVED FIXED
Alias: None
Product: JacORB
Classification: Unclassified
Component: ORB (show other bugs)
Version: 3.6.1
Hardware: PC All
: P5 enhancement
Assignee: Mailinglist to track bugs
URL:
Depends on:
Blocks:
 
Reported: 2016-01-26 08:05 UTC by Jens Vagts
Modified: 2016-01-31 02:19 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Vagts 2016-01-26 08:05:12 UTC
As of jacorb 3.7, the identification of the local hosts address used or for the IORs is done by some ordering of all found network addresses in org.jacorb.orb.iiop.IIOPAddress.getNetworkInetAddresses() and returning just the first one in org.jacorb.orb.iiop.IIOPAddress.getLocalHost().
So the order of network interfaces and addresses defined in the system is important for the local (remote) address to be used for the service references.
I suggest to use the local host address returned via java.net.InetAddress.getLocalHost() to be used as a kind as 'preferred' (first) service address in the getNetworkInetAddresses() sort order.

This would solve even a special minor issue we have have with 'local networks': some computers connected to a private network without a domain controller to a network hub and 'auto configured' (DHCP) will get a link local address (169.254.x.x, see https://en.wikipedia.org/wiki/Link-local_address). Currently jacorb binds the services to loppback address, since it's ordered before the link local address (on windows 7 computers). InetAddress.getLocalHost() returnes the link local address here.
Comment 1 Nick Cross 2016-01-28 03:25:59 UTC
What system are you running on? (Windows?)

What is the output of "jaco org.jacorb.util.Diagnostic" and what does java.net.InetAddress.getLocalHost() give you? 

Its possible the ordering under Linux/Mac is different to that under Windows.

Regarding link local/loopback - perhaps their ordering should be split so link local is first, then finally loopback.
Comment 2 Jens Vagts 2016-01-29 02:28:46 UTC
Yes we and our customers are running windows.

I should have named this bug to our main problem with the local networks some of our customers have in their laboratories instead describing a possible solution, sorry. If you just change the ordering to prefer link local and loopback finally we would be totally fine for this issue!

The idea to use the java.net.InetAddress.getLocalHost() as the 'preferred' (first) address came into mind, because it delivers the same address than 'ipconfig /all' marks with the suffix '(Preferred)'.
This would solve issues were computers have multiple network adapters included (e.g. a computer controlling a instrument connected to a dedicated device network card). Jacorb than depends on the order of the configured network cards within the system. InetAddress.getLocalHost() would point always to the remote/domain network with the drawback to depend on the DNS lookup far as I understand.

On our test system, having localy connected computers (three computers configured with DHCP but connected to a switch without DHCP server), jaco org.jacorb.util.Diagnostic" gives following output:
--------------------------------
JacORB Version: JacORB V3.7 (www.jacorb.org)
        (C) The JacORB project 1997-2015
        03 November 2015 with SHA b691766e

Operating system name: Windows Server 2012 R2
Operating system version: 6.3
Operating system architecture: amd64
Java Vendor: Oracle Corporation
Java Version: 1.8.0_72
Runtime max memory: 3632M

Found the following network addresses:
    /127.0.0.1 / 127.0.0.1
    /0:0:0:0:0:0:0:1 / hbeswprotein6
    /169.254.196.215 / hbeswprotein6
Preferred non-loopback address /127.0.0.1

Default locale en_US (which is English (United States))
System file encoding property: Cp1252
Cannonical encoding: Cp1252
Default WChar encoding: UTF16

Created ORB org.jacorb.orb.ORB
--------------------------------

On the same computer "java.net.InetAddress.getLocalHost()" points to "169.254.196.215" which is the desired/correct address and is marked as "(Preferred)" by ipconfig.
Comment 3 Nick Cross 2016-01-31 02:19:37 UTC
Fixed by edaa8d17ad1573ce9f357c664bd578367e7b3327