Archived
This forum has been archived. Please start a new discussion on GitHub.
Problem using IceGrid administrative session
The following code:
std::string registryProxyStr = "IceGrid/Registry:tcp -p 4061";
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
communicator->stringToProxy(registryProxyStr));
try
{
IceGrid::AdminSessionPrx session = registry->createAdminSession(
user, password);
session->keepAlive();
}
catch (Ice::Exception const & e)
{
// print out exception
throw;
}
produces an ObjectNotExist exception when invoking keepAlive on the session proxy:
object does not exist:
identity: `IceGrid/d542d531-7e39-4102-9d5f-23914df22e6c'
facet:
operation: keepAlive
I don't understand why the proxy just given to me by the registry would not point to an existing object.
I run the registry on the same box as the program. The IceGrid Admin GUI shows the registry dynamic well known object: IceGrid/Registry -t:tcp -h 10.20.5.167 -p 4061. registry->ice_toString() gives "IceGrid/Registry -t:tcp -h 127.0.0.1 -p 4061". session->ice_toString() gives "IceGrid/d542d531-7e39-4102-9d5f-23914df22e6c -t:tcp -h 10.20.5.167 -p 4061"
Any help is appreciated.
std::string registryProxyStr = "IceGrid/Registry:tcp -p 4061";
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
communicator->stringToProxy(registryProxyStr));
try
{
IceGrid::AdminSessionPrx session = registry->createAdminSession(
user, password);
session->keepAlive();
}
catch (Ice::Exception const & e)
{
// print out exception
throw;
}
produces an ObjectNotExist exception when invoking keepAlive on the session proxy:
object does not exist:
identity: `IceGrid/d542d531-7e39-4102-9d5f-23914df22e6c'
facet:
operation: keepAlive
I don't understand why the proxy just given to me by the registry would not point to an existing object.
I run the registry on the same box as the program. The IceGrid Admin GUI shows the registry dynamic well known object: IceGrid/Registry -t:tcp -h 10.20.5.167 -p 4061. registry->ice_toString() gives "IceGrid/Registry -t:tcp -h 127.0.0.1 -p 4061". session->ice_toString() gives "IceGrid/d542d531-7e39-4102-9d5f-23914df22e6c -t:tcp -h 10.20.5.167 -p 4061"
Any help is appreciated.
0
Comments
-
Hi,
Most likely, the keepAlive request is not sent over the connection that was used to create the session. Session objects can only be accessed from the network connection used to create the session for security reasons.
This can happen if the session proxy endpoints don't match the endpoints of the registry proxy (different timeout or IP address). Did you trying to print the session proxy? You could also enable Ice.Trace.Network=2 and Ice.Trace.Protocol=1 on the client to see if another network connection is being used to send the keepAlive request.
Cheers,
Benoit.0 -
Thanks. The proxy strings are in the original post. Yes, of course you are right - the endpoints turn out to be different, although they both (127.0.0.1:4061 and 10.20.5.167:4061) refer to the same host. Here is the log:
[ 03/03/08 12:43:22.615 Network: attempting to bind to tcp socket 127.0.0.1:0 ]
[ 03/03/08 12:43:22.630 Network: accepting tcp connections at 127.0.0.1:3108 ]
[ 03/03/08 12:43:23.443 Network: attempting to bind to tcp socket 10.20.5.167:0 ]
[ 03/03/08 12:43:23.443 Network: accepting tcp connections at 10.20.5.167:3111 ]
[ 03/03/08 12:43:23.458 Network: attempting to bind to tcp socket 127.0.0.1:0 ]
[ 03/03/08 12:43:23.458 Network: accepting tcp connections at 127.0.0.1:3114 ]
[ 03/03/08 12:43:23.458 Network: trying to establish tcp connection to 127.0.0.1:4061 ]
[ 03/03/08 12:43:23.458 Network: tcp connection established
local address = 127.0.0.1:3115
remote address = 127.0.0.1:4061 ]
[ 03/03/08 12:43:23.458 Protocol: received validate connection
message type = 3 (validate connection)
compression status = 0 (not compressed; do not compress response, if any)
message size = 14 ]
[ 03/03/08 12:43:23.458 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 74
request id = 1
identity = IceGrid/Registry
facet =
operation = ice_isA
mode = 1 (nonmutating)
context = ]
[ 03/03/08 12:43:23.458 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 26
request id = 1
reply status = 0 (ok) ]
[ 03/03/08 12:43:24.130 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 64
request id = 2
identity = IceGrid/Registry
facet =
operation = getSessionTimeout
mode = 1 (nonmutating)
context = ]
[ 03/03/08 12:43:24.130 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 29
request id = 2
reply status = 0 (ok) ]
[ 03/03/08 12:43:24.740 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 79
request id = 3
identity = IceGrid/Registry
facet =
operation = createAdminSession
mode = 0 (normal)
context = ]
[ 03/03/08 12:43:24.740 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 105
request id = 3
reply status = 0 (ok) ]
[ 03/03/08 12:43:25.146 Network: trying to establish tcp connection to 10.20.5.167:4061 ]
[ 03/03/08 12:43:25.146 Network: tcp connection established
local address = 10.20.5.167:3118
remote address = 10.20.5.167:4061 ]
[ 03/03/08 12:43:25.146 Protocol: received validate connection
message type = 3 (validate connection)
compression status = 0 (not compressed; do not compress response, if any)
message size = 14 ]
[ 03/03/08 12:43:25.552 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 84
request id = 1
identity = IceGrid/d198bfed-ca7f-4031-9ee4-394b1ce3059f
facet =
operation = keepAlive
mode = 2 (idempotent)
context = ]
[ 03/03/08 12:43:25.552 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 77
request id = 1
reply status = 2 (object not exist)
identity = IceGrid/d198bfed-ca7f-4031-9ee4-394b1ce3059f
facet =
operation = keepAlive ]
[ 03/03/08 12:43:26.630 Network: stopping to accept tcp connections at 10.20.5.167:3111 ]
[ 03/03/08 12:43:26.630 Network: stopping to accept tcp connections at 127.0.0.1:3114 ]
[ 03/03/08 12:43:26.630 Protocol: sending close connection
message type = 4 (close connection)
compression status = 1 (not compressed; compress response, if any)
message size = 14 ]
[ 03/03/08 12:43:26.630 Protocol: sending close connection
message type = 4 (close connection)
compression status = 1 (not compressed; compress response, if any)
message size = 14 ]
[ 03/03/08 12:43:26.630 Network: shutting down tcp connection for writing
local address = 127.0.0.1:3115
remote address = 127.0.0.1:4061 ]
[ 03/03/08 12:43:26.630 Network: closing tcp connection
local address = 127.0.0.1:3115
remote address = 127.0.0.1:4061 ]
[ 03/03/08 12:43:26.630 Network: shutting down tcp connection for writing
local address = 10.20.5.167:3118
remote address = 10.20.5.167:4061 ]
[ 03/03/08 12:43:26.630 Network: closing tcp connection
local address = 10.20.5.167:3118
remote address = 10.20.5.167:4061 ]
03/03/08 12:43:27.521 error: ServiceManager: exception while starting service ServerMonitor:
Outgoing.cpp:388: Ice::ObjectNotExistException:
object does not exist:
identity: `IceGrid/d198bfed-ca7f-4031-9ee4-394b1ce3059f'
facet:
operation: keepAlive
[ 03/03/08 12:43:27.521 Network: stopping to accept tcp connections at 127.0.0.1:3108 ]
Here is what I've done to go around this problem:
IceGrid::AdminSessionPrx session =
registry->createAdminSession(user, password);
Ice::ConnectionPtr conn = registry->ice_getConnection();
Ice::ObjectPrx prx = conn->createProxy(session->ice_getIdentity());
session = IceGrid::AdminSessionPrx::uncheckedCast(prx);
// session->ice_toString());
session->keepAlive();
Is this right? It seems to work. For some reason "session->ice_toString()" throws a FixedProxyException
Thanks0 -
Thanks. The proxy strings are in the original post. Yes, of course you are right - the endpoints turn out to be different, although they both (127.0.0.1:4061 and 10.20.5.167:4061) refer to the same host. Here is the log:
[ 03/03/08 12:43:22.615 Network: attempting to bind to tcp socket 127.0.0.1:0 ]
[ 03/03/08 12:43:22.630 Network: accepting tcp connections at 127.0.0.1:3108 ]
[ 03/03/08 12:43:23.443 Network: attempting to bind to tcp socket 10.20.5.167:0 ]
[ 03/03/08 12:43:23.443 Network: accepting tcp connections at 10.20.5.167:3111 ]
[ 03/03/08 12:43:23.458 Network: attempting to bind to tcp socket 127.0.0.1:0 ]
[ 03/03/08 12:43:23.458 Network: accepting tcp connections at 127.0.0.1:3114 ]
[ 03/03/08 12:43:23.458 Network: trying to establish tcp connection to 127.0.0.1:4061 ]
[ 03/03/08 12:43:23.458 Network: tcp connection established
local address = 127.0.0.1:3115
remote address = 127.0.0.1:4061 ]
[ 03/03/08 12:43:23.458 Protocol: received validate connection
message type = 3 (validate connection)
compression status = 0 (not compressed; do not compress response, if any)
message size = 14 ]
[ 03/03/08 12:43:23.458 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 74
request id = 1
identity = IceGrid/Registry
facet =
operation = ice_isA
mode = 1 (nonmutating)
context = ]
[ 03/03/08 12:43:23.458 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 26
request id = 1
reply status = 0 (ok) ]
[ 03/03/08 12:43:24.130 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 64
request id = 2
identity = IceGrid/Registry
facet =
operation = getSessionTimeout
mode = 1 (nonmutating)
context = ]
[ 03/03/08 12:43:24.130 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 29
request id = 2
reply status = 0 (ok) ]
[ 03/03/08 12:43:24.740 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 79
request id = 3
identity = IceGrid/Registry
facet =
operation = createAdminSession
mode = 0 (normal)
context = ]
[ 03/03/08 12:43:24.740 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 105
request id = 3
reply status = 0 (ok) ]
[ 03/03/08 12:43:25.146 Network: trying to establish tcp connection to 10.20.5.167:4061 ]
[ 03/03/08 12:43:25.146 Network: tcp connection established
local address = 10.20.5.167:3118
remote address = 10.20.5.167:4061 ]
[ 03/03/08 12:43:25.146 Protocol: received validate connection
message type = 3 (validate connection)
compression status = 0 (not compressed; do not compress response, if any)
message size = 14 ]
[ 03/03/08 12:43:25.552 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 84
request id = 1
identity = IceGrid/d198bfed-ca7f-4031-9ee4-394b1ce3059f
facet =
operation = keepAlive
mode = 2 (idempotent)
context = ]
[ 03/03/08 12:43:25.552 Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 77
request id = 1
reply status = 2 (object not exist)
identity = IceGrid/d198bfed-ca7f-4031-9ee4-394b1ce3059f
facet =
operation = keepAlive ]
Here is what I've done to go around this problem:
IceGrid::AdminSessionPrx session =
registry->createAdminSession(user, password);
Ice::ConnectionPtr conn = registry->ice_getConnection();
Ice::ObjectPrx prx = conn->createProxy(session->ice_getIdentity());
session = IceGrid::AdminSessionPrx::uncheckedCast(prx);
// session->ice_toString());
session->keepAlive();
Is this right? It seems to work. For some reason "session->ice_toString()" throws a FixedProxyException
Thanks0 -
While this works, you would have to do this for each proxy returned by the admin session (the proxy of the admin object, etc). Instead, I would recommend to use the well-known proxy to create the IceGrid::Registry proxy and configure the Ice.Default.Locator property (Ice.Default.Locator="IceGrid/Locator:tcp -p 4061"), for example:
// C++ Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Registry"); IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(obj); try { IceGrid::AdminSessionPrx session = registry->createAdminSession(user, password); session->keepAlive(); } catch(const Ice::Exception& ex) { cerr << ex << endl; throw; }
Thanks to the Ice locator, the Ice runtime will retrieve the correct endpoints for the IceGrid/Registry object. These endpoints will be the same as the endpoints of the session proxy and you shouldn't have any more issues.
Cheers,
Benoit.0 -
Thanks a bunch. It worked.0