Archived

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

Using Glacier2 with no default router

I'm a little confused about using Glacier2 without the Ice.Default.Router property being set. What I think I have to do is the following:

1. Create an object adapter with a router specified as is documented in the example in the manual as follows:

Ice.Default.Router=Glacier2/router:tcp -h 5.6.7.8 -p 8000

2. Then creating a router session. When using the default router it is easy to get a a RouterPrx by just using the communicator. But when specifying a router for the object adapter there is no obvious way of getting a RouterPrx which is needed to create the session.

I tried using the communicator as follows:

communicatorr()->stringToProxy("Glacier2/router:ssl -h 5.6.7.8 -p 8000");

and then casting to a RouterPrx, but this didn't appear to work for me either.

Any suggestions?

Regards --Roland

Comments

  • matthew
    matthew NL, Canada
    rhochmuth wrote:
    I'm a little confused about using Glacier2 without the Ice.Default.Router property being set. What I think I have to do is the following:

    1. Create an object adapter with a router specified as is documented in the example in the manual as follows:

    Ice.Default.Router=Glacier2/router:tcp -h 5.6.7.8 -p 8000

    2. Then creating a router session. When using the default router it is easy to get a a RouterPrx by just using the communicator. But when specifying a router for the object adapter there is no obvious way of getting a RouterPrx which is needed to create the session.

    I tried using the communicator as follows:

    communicatorr()->stringToProxy("Glacier2/router:ssl -h 5.6.7.8 -p 8000");

    and then casting to a RouterPrx, but this didn't appear to work for me either.

    Any suggestions?

    Regards --Roland

    For the example that you have above you need:

    - For the glacier2 configuration set:

    Glacier2.Client.Endpoints=ssl -h 5.6.7.8 -p 8000

    and then later you need the setup the ssl configuration correctly.

    - For the client application then you can use:

    communicator()->stringToProxy("Glacier2/router:ssl -h 5.6.7.8 -p 8000");

    and then cast the proxy to a router.

    Regards, Matthew
  • Hi Mathew, Thanks for the info. I mistyped the ssl and tcp in my example. I'm using ssl everywhere. My code was working when I used the Ice.Default.Router property. Here is what I'm trying to do now.

    // Get proxy to router and recast.
    Ice::ObjectPrx proxy = _communicator->stringToProxy("Glacier2/router:ssl -h 15.1.89.49 -p 8000");
    Ice::RouterPrx routerPrxy = Ice::RouterPrx::checkedCast(proxy);

    // Create the object adapter.
    std::string adapterEndpoint("tcp -p 0:ssl -p 0 -h " + ipAddress);
    adapter = _communicator->createObjectAdapterWithEndpoints(IceUtil::generateUUID(),
    adapterEndpoint);

    // Add the router to the object adapter.
    adapter->addRouter(routerPrxy);

    ...

    // Create the router session
    Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerPrxy);
    ...

    My code is failing on the addAdapter with a ConnectionLostException.

    Regards --Roland
  • You get a ConnectionLostException if no session has been created, i.e., every request to Glacier2 without having created a session first will result in Glacier2 simply dropping the connection (as a security measure, to disallow any requests for unauthorized clients).

    How do you exactly create the session? Also, do you perhaps open more than one connection to Glacier2, for example, because you use proxies with different timeout settings? Since sessions are bound to connections, you must make sure that there is only one connection. You can check connection usage with network tracing (Ice.Trace.Network=2).
  • I also just noticed that you create the session after adding the router to the object adapter. Try to create the session first, before adding the router to the object adapter.
  • Hi Marc, Thanks for the pointer on creating the session first. That was part of the solution. I now have the router being partially used. It appears that some of my proxies are being routed correctly, and some are bypassing the router. I'm still stepping through resolving issues.

    Regards --Roland
  • You had stated that sessions are bound to connections previousely and I think that this might be a clue. When my application runs without Glacier2, I have both tcp and ssl proxies/connections being used simultaneousely. We had performance critical paths that didnt' need to be secure and non-performance critical paths that needed to be secure.

    When I use Glacier2 I'm just creating one router and one session as a result. Do I need to create two routers and two sessions?

    Currently, for all the proxies that I create, I just cast using ice_router with the same router for all proxies whether they are tcp or ssl. Interestingly, when I used the Ice.Default.Router property this all appeared to work.

    Regards --Roland
  • If you use a router, then the protocol settings of proxies for server objects are only relevant for the communications between the router and the server. All communications between the client and the router use the protocol settings specified by the router proxy.

    If you want client<->router communications for both TCP and SSL, then you must create two sessions, one for each of the two protocols. However, since creating a session involves sending the password along with the user-id, it is dangerous to use TCP for such communications, except in a trusted environment. On the other hand, if the environment is tusted anyway, then there is no need to use SSL. So my recommendation is to either use TCP or SSL, but not both.

    If you use a default router, then you can implicitly only use one protocol, because you can specify only one router proxy. This might explain why the behavior is different if you use a default router compared to per-proxy routers.
  • Thanks Marc, I'm up and running. It took me a little while to trace through my system. The main thing was to create the session first and then the object adapter. Once this was done I just had to be more careful creating proxies and casting correctly to use ice_router. I was also a little confused on the session discussion. It took me a litle while to understand that a router proxy is just like any other proxy in the system and that creating a session is just like authenticating.

    I'm only using ssl between the client and router so one session is working fine now. For a moment I also thought that I had to create multiple sessions since I was using ssl and tcp in the client. Thanks again for all your help and for clarifying the sessions.

    Regards --Roland