This forum has been archived. Please start a new discussion on GitHub.

NodeJS callback implementation


I am trying to prototype a few things before using ZeroC RPC framework. Scheme is pretty straightforward. We are having some ServiceFactory, which returns Service, which is providing some functionality and invoke callback on result competition.
Server side is C++ and client side is NodeJS and Java. Java work pretty well - no question here, but I am stuck with Node JS part.

I am creating a listener in JS code and trying to pass it to service. Please see code snippet below(sorry for formatting):
return ic.createObjectAdapter("").then(
var r = adapter.addWithUUID(new CoolResultListenerI());
return SRV.CoolResultListenerPrx.checkedCast(r).then(

No luck here. Ice is throwing an error with valid ID but strange EP:

proxy: "8d3a083f-5814-40b9-e3f2-a928050e71f9 -t -e 1.1"

When I am trying to create an adapter with local EP(createObjectAdapterWithEndpoints):

unsupportedFeature: "object adapter endpoints not supported"

After reviewing docs/samples (where no Prx was used but Ice::Identity) can I conclude that this current approach doesn't work with ZeroC ICE ? (at least 3.6.*) version.

Thank you!

ps. Overall test is here


  • gkorovkin
    edited July 2017

    Sorry for borrowing you - found solution.

                                    var prx = adapter.createProxy(r.ice_getIdentity());

    But now I have an exception on server side :)
    terminating with uncaught exception of type Ice::NoEndpointException: Reference.cpp:1676: Ice::NoEndpointException:
    no suitable endpoint available for proxy `f2d96ae4-b84a-4697-8463-4b8e6c30b003 -t -e 1.1'

    Could you please help me on that?

  • xdm
    xdm La Coruña, Spain

    Hi Gin,

    The problem is that you are sending a proxy to the server and that defeats the purpose of using a bidirectional connection see Bidirectional Connections page in Ice manual.

    You want to instead send the Identity of the CoolResultListener object and let the server create the proxy using the connection.

    Take a look at the bidirectional demos:

    JS Client

    return communicator.createObjectAdapter("").then(
            // Create a callback receiver servant and add it to
            // the object adapter.
            var r = adapter.addWithUUID(new CallbackReceiverI());
            // Set the connection adapter.
            // Register the client with the bidir server.
            return server.addClient(r.ice_getIdentity());

    C++ Server

    CallbackSenderI::addClient(const Identity& ident, const Current& current)
        IceUtil::Monitor<IceUtil::Mutex>::Lock lck(*this);
        cout << "adding client `" << _communicator->identityToString(ident) << "'"<< endl;
        CallbackReceiverPrx client = CallbackReceiverPrx::uncheckedCast(current.con->createProxy(ident));
  • Thanks, Jose!

    Correct me if I wrong:

    • IDL file declared properly
    • Stubs and code generated with no errors or warnings

    But there is no possibility to use this declared semantic using JavaScript bindings?

  • xdm
    xdm La Coruña, Spain

    The only way that your C++ server can call to your JavaScript client is using a bidirectional connection.