Archived

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

HelloWorld application with IcePack

Hi,

I should say that ICE is great, but...

a little bit confusing, that I have to read thousand of pages to find out how to use an object if the server runs on a different host, because the '-h xxx.xxx.xxx.xxx' possibilty is mentioned at the very end of the documentation first time. Actually, at the 2.0 documentation, it is mentioned at the page 674 first time, about the adapter config. At the very beginning it is a very exiting problem to solve. I suggest you to put some sentences about it into the chapter 3.

When I was studying how to use ICE
1. I tried to develop a HelloWorld server an client on the same machine
// the Chapter 3 was great to do that
2. I tried to separate the server and the client into different machines
// I have to read the half of the documentation to do that
3. I tried to improve the client to find the server automatically somewhere
to use // at this time I don't know how to do that :(

After reading a great number of pages again, now I can't find out, how to create a simple HelloWorld project if the adapter must be found trough the icepack registry. The 33.3.2 chapter is too short, and says nothing to a developer, who has no deep knowledge on this topic. The DEMO on IcePack uses an Factory, which is not the simplest example, and the client code is too complicated because does too much things. There is no simple (minimal) example on this topic. Now it is not clear for me what is a Factory, and is it really needed to use the IcePack regisrty to find an object. The chapter says nothing about ut.

May suggestions are:
- this topic really needs a little working example
- with a simple HelloWorld server and the minimal config file to work
- a very simple HelloWorld client with minimal config file
- a short description how to start the IcePack registry
- a short description how to check if the object adapter and object
itself is registered properly to the IcePack registry (maybe using the
IcePack Admin app ???)

Please, somebody help me now, how to do those things, because I cannot use these technics now!! A working sample program and a short readme would be greatful now!

thx in advance

Comments

  • After reading a lot, I was able to register my adapter into the registry - or else I was able to detect it using the 'adapter list' command from the IcePackAdmin tool. It is not clear when will an registered adapter be unregistered, or how can I unregister it by hand.

    That is not clear too, when an adapter is registered, then all the objects will be registered automatically too? Or at least I wasn't able to find my object using the "object find ::HelloObj" command.

    What is wrong ?
  • mes
    mes California
    Registering an object adapter allows you to use the "object@adapter" syntax in indirect proxies. Registering an object allows you to use the "object" syntax in indirect proxies.

    Registering an object adapter does not automatically cause all objects activated on that object adapter to also be registered. You must explicitly register an object, either by using icepackadmin, or by invoking addObject on the registry.

    Take care,
    - Mark
  • Ok. That is an answer for some question. If I understand you well, my adapter is registered - my objects not. So the "object find ::HelloObj" won't work. But my client.exe drops an "NoEndPointException" when the proxy is HelloObj@MyAdapter.

    Ice.ObjectPrx basePrx = communicator.stringToProxy("HelloObj@MyAdapter");

    The book suggest me to set the Ice.Tracer.Locator to 1. The ICE says it is an unknown property...

    aroan
  • mes
    mes California
    If you are using Ice 1.5.1, please see this thread for more information on an IcePack bug involving dynamic adapter registration.

    The property you should use is Ice.Trace.Location. We will update the manual to correct this mistake.

    Take care,
    - Mark
  • I use ICE 2.0 and C#.

    The IcePackRegistry config is
    on 192.168.1.112
    Ice.Default.Locator=IcePack/Locator:default -p 12000
    IcePack.Registry.Client.Endpoints=default -p 12000
    IcePack.Registry.Server.Endpoints=default
    IcePack.Registry.Admin.Endpoints=default
    IcePack.Registry.Data=db/registry
    IcePack.Registry.DynamicRegistration=1


    The server program is:
    on 192.168.1.112
    Ice.Communicator communicator = null;
    Ice.Properties properties = Ice.Util.createProperties(ref args);
    properties.load("config");
    communicator = Ice.Util.initializeWithProperties(ref args, properties);
    Ice.ObjectAdapter adapter = communicator.createObjectAdapter("MyAdapter");
    Ice.Object obj = new HelloI();
    adapter.add(obj, Ice.Util.stringToIdentity("HelloObj"));
    adapter.activate();

    The server "config" file is:
    Ice.Default.Locator=IcePack/Locator:default -p 12000
    MyAdapter.AdapterId=MyAdapter
    MyAdapter.Register=true
    MyAdapter.EndPoints=default


    The client program is:
    Ice.Communicator communicator = null;
    Ice.Properties properties = Ice.Util.createProperties(ref args);
    properties.load("config");
    communicator = Ice.Util.initializeWithProperties(ref args, properties);
    Ice.Properties properties = communicator.getProperties();
    Ice.ObjectPrx basePrx = communicator.stringToProxy("HelloObj@MyAdapter");
    HelloPrx twoway = HelloPrxHelper.checkedCast(basePrx.ice_twoway().ice_timeout(-1).ice_secure(false));

    and the client "config" file is:
    Ice.Default.Locator=IcePack/Locator:default -h 192.168.1.112 -p 12000


    The server and the IcePackRegistry is running on 192.168.1.112, the client
    is running on 192.168.1.111. But it produces the same error when they are on the same host.

    The server works correctly as far as I know, because the IcePackAdmin "adapter list" shows the MyAdapter. But the "object find ::HelloObj::MyAdapter::" shows ObjectNoxExistsException.

    The client drops an NoEndPointException.

    CLIENT TRACE
    P:\ICE\proba\HelloWorld\Solution1\Hello_Client\bin\Debug>hello_client
    loading properties from file 'config'...
    [ Hello_Client.exe: Network: trying to establish tcp connection to 192.168.1.112
    :12000 ]
    [ Hello_Client.exe: Network: tcp connection established
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Network: received 14 of 14 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Protocol: received validate connection
    message type = 3 (validate connection)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 14 ]
    [ Hello_Client.exe: Protocol: sending request
    message type = 0 (request)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 69
    request id = 1
    identity = IcePack/Locator
    facet =
    operation = findAdapterById
    mode = 1 (nonmutating)
    context = ]
    [ Hello_Client.exe: Network: sent 69 of 69 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Network: received 14 of 14 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Network: received 13 of 13 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Protocol: received reply
    message type = 2 (reply)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 27
    request id = 1
    reply status = 0 (ok) ]
    [ Hello_Client.exe: Protocol: sending request
    message type = 0 (request)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 69
    request id = 2
    identity = IcePack/Locator
    facet =
    operation = findAdapterById
    mode = 1 (nonmutating)
    context = ]
    [ Hello_Client.exe: Network: sent 69 of 69 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Network: received 14 of 14 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Network: received 13 of 13 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Protocol: received reply
    message type = 2 (reply)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 27
    request id = 2
    reply status = 0 (ok) ]
    Ice.NoEndpointException: NoEndpointException
    at IceInternal.ProxyFactory.checkRetryAfterException(LocalException ex, Int32
    cnt)
    at Ice.ObjectPrxHelperBase.__handleException(LocalException ex, Int32 cnt)
    at Ice.ObjectPrxHelperBase.ice_isA(String __id, Context __context)
    at Ice.ObjectPrxHelperBase.ice_isA(String __id)
    at Proba.HelloPrxHelper.checkedCast(ObjectPrx b) in P:\ICE\proba\HelloWorld\S
    olution1\Hello_Client\Hello.cs:line 313
    at Client.run(String[] args, Communicator communicator) in p:\ice\proba\hello
    world\solution1\hello_client\client.cs:line 26
    at Client.Main(String[] args) in p:\ice\proba\helloworld\solution1\hello_clie
    nt\client.cs:line 140
    [ Hello_Client.exe: Protocol: sending close connection
    message type = 4 (close connection)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 14 ]
    [ Hello_Client.exe: Network: sent 14 of 14 bytes via tcp
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Network: shutting down tcp connection
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
    [ Hello_Client.exe: Network: closing tcp connection
    local address = 192.168.1.110:4894
    remote address = 192.168.1.112:12000 ]
  • mes
    mes California
    Your server's configuration file contains an error. The following property is spelled incorrectly:

    MyAdapter.EndPoints=default

    It should be

    MyAdapter.Endpoints=default

    Take care,
    - Mark
  • Ok. But it is still not working...
  • mes
    mes California
    I was able to reproduce this using your configuration. Things should work if you define the following property in the registry's configuration:

    IcePack.Registry.Internal.Endpoints=default

    We will review the IcePack implementation to see whether this should really be necessary.

    - Mark
  • Man, I should say: YOU ARE A GENIUS! IT IS WORKING NOW!

    The worst thing is, that in the DOC 2.0 on the page 883 on chapter 33.5.7 it says 'minimal configuration', and your config set is not on that page! That is why I haven't set that value - but uncomment that instead :-). Because the Registry gives me a security warning when it is enabled - and the doc says it is not needed!

    thansk a lot !!!!

    aroan
    who is happy now again! :)