How to specify the network interface when using Naming Service lookup using Oracle Java ORB

326 Views Asked by At

So I'm currently hosting a service which utilizes Oracle's Interoperable Naming Service (INS) according to tutorial listed below. This service deploys a servant on one machine and registers it with the INS, we'll call this machine A.

Properties properties = System.getProperties( );
properties.put( "com.sun.CORBA.POA.ORBPersistentServerPort",
    Integer.toString(1060);
ORB orb = ORB.init( args, properties );
ServiceImpl servant = new ServiceImpl( );
POA rootPOA = POAHelper.narrow( orb.resolve_initial_references( "RootPOA" ));
rootPOA.the_POAManager().activate();
rootPOA.activate_object( servant );
((com.sun.corba.se.impl.orb.ORBImpl) orb).
    register_initial_reference("PingService", 
        rootPOA.servant_to_reference(servant));
System.out.println( "INS Server is Ready...");
orb.run();

https://docs.oracle.com/javase/8/docs/technotes/guides/idl/INStutorial.html

When I use a client on the same machine according to the tutorial, everything works just fine. However, when I attempt to do a lookup over LAN, when the INS Server is hosted on Machine A and the client is on Machine B I get an error when narrowing the reference.

String[] argv = new String[]{"-ORBInitRef",
    "PingService=corbaloc:iiop:1.2@" 
    + ORBIP + ":" + ORBPort + "/PingService"};
ORB orb = ORB.init( argv, null );

org.omg.CORBA.Object object = orb.resolve_initial_references(
    "PingService" );

Service fileRef = ServiceHelper.narrow( object ); // <----- error

I set the server as 192.168.0.XXX and it is accessible by machine B, and get error somewhere along these lines. AFAIK the connection is being made to the naming service and the object located in the service, but when it tries to look up the object it uses an incorrect interface on machine A. Then the error is returned to machine B.

com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init>
WARNING "IOP00410201: (COMM_FAILURE)Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port:1060"
org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No
connectFailure

So my question is, is there a way to specify exactly which interface the naming service can use when it does the lookup? I tried on both a Windows host and a Linux host. The linux host used an iface which wasn't listed but was in the /etc/hosts file and the Windows host used an IP of the last interface listed in ipconfig (a 172.xx.. IP). Tested both on vbox with bridge enabled. Is there an effective way to specify the network interface? My requirement is for the server and client to exist independently on the same LAN. Setting the ORBInitialHost property on the server didn't do anything.

1

There are 1 best solutions below

0
On

the problem here is that the client machine is searching for the server locally this why it's writing Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port:1060 So in the client code instead of initializing the properties like this :

String[] argv = new String[]{"-ORBInitRef", "PingService=corbaloc:iiop:1.2@" 
+ ORBIP + ":" + ORBPort + "/PingService"};
ORB orb = ORB.init( argv, null );

try initializing it like this :

    Properties props = new Properties();
    props.put("org.omg.CORBA.ORBInitialHost",ORBIP);
    props.put("org.omg.CORBA.ORBInitialPort","1060");
    ORB orb = ORB.init(args,props);

in the ORBIP variable put the server IP address in the LAN . you tried the ORBInitialHost property on the server but it doesn't do anything because he's running locally . this property must be used in the client side to know the exact hosting point of the server.