Home Help Center

specifying proxy's locator

n2503vn2503v Member Alex MakarenkoOrganization: ACFR, University of SydneyProject: Orca ✭✭✭
I have two indirect proxies and I want them to use two different locators. According to sec. 30.16.3 this can be done in 3 ways. I try 2 of them: by calling prx->ice_locator() and by calling comm->setDefaultLocator(). Both seem to have no effect: the proxies always get resolved through the original default locator.

Short sample code is below with debugging lines removed. BTW, I use ice_ping() and ice_connection() to see which objects the proxies resolve. for example:

int App::run( int argc, char* argv[] )
// first locator
Ice::ObjectPrx olocA = communicator()->stringToProxy( "IceGrid/Locator: default -h remotehost -p 12000" );
Ice::LocatorPrx locA = Ice::LocatorPrx::checkedCast( olocA );
communicator()->setDefaultLocator( locA );

// create a proxy, it uses default locator (WORKS FINE)
Ice::ObjectPrx oadminA = communicator()->stringToProxy("IceGrid/Admin");

// define new locator
Ice::ObjectPrx olocB = communicator()->stringToProxy( "IceGrid/Locator:tcp -h localhost -p 12005" );
Ice::LocatorPrx locB = Ice::LocatorPrx::checkedCast( olocB );

// another proxy, change locator directly (DOES NOT WORK)
Ice::ObjectPrx oadminB = communicator()->stringToProxy("IceGrid/Admin");
oadminB = oadminB->ice_locator( locB );

// change the default locator
communicator()->setDefaultLocator( locB );

// create another proxy, should use the new locator (DOES NOT WORK)
Ice::ObjectPrx oadminC = communicator()->stringToProxy("IceGrid/Admin");

return 0;

here's the output (with ip addresses replaced with x.x.x). Note how "thru locator B" entries should go to localhost on but they go to the remote host.

default locator :IceGrid/Locator -t:tcp -h remotehost -p 12000

thru default locator :
local address = 129.x.x.x:60767
remote address = 172.x.x.x:32855

thru default locator 2:
local address = 129.x.x.x:60767
remote address = 172.x.x.x:32855

locator B:
local address =
remote address =

thru locator B :
local address = 129.x.x.x:60767
remote address = 172.x.x.x:32855

new default locator :IceGrid/Locator -t:tcp -h localhost -p 12005

thru locator B as default :
local address = 129.x.x.x:60767
remote address = 172.x.x.x:32855


  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    You need to use different object identities for your different locators. See IceGrid.InstanceName.

    The Ice runtime uses these identities as keys of its local Locator caches.

  • n2503vn2503v Member Alex MakarenkoOrganization: ACFR, University of SydneyProject: Orca ✭✭✭
    Thanks Bernard,

    made it all clear and it works now.

    just a side note... as I was playing with the Ice::ObjectPrx interface, it seemed to me that it's slightly inconsistent.

    there're several functions which come in pairs, basically getXXX and newXXX, e.g.

    Context ice_getContext();
    Object* ice_newContext(Context ctx);

    and then there those which only have newXXX, but the name does not reflect it, e.g.
    Object* ice_router(Router* rtr);
    Object* ice_locator(Locator* loc);

    I guess there're must be a reason why you don't have something like this:
    Locator* ice_getLocator();
    Object* ice_newLocator(Locator* loc);

    cheers, alex
Sign In or Register to comment.