Archived

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

reply status = 2 (object not exist)

I write a similar icebox service like newsletter,when debug it,always report "object not exist",
snippet:
UserServiceI.cpp:
namespace NW
{
namespace Users
{
class UserServiceI : public ::IceBox::Service
{
public:
virtual void
start(const string& name, const CommunicatorPtr& communicator, const StringSeq&)
{ _adapter = communicator->createObjectAdapter("UserManager");
IdIndexPtr index = new IdIndex("userid");
vector<Freeze::IndexPtr> indices;
indices.push_back(index);
UserManagerIPtr manager = new UserManagerI(index,_adapter);
UserFactoryPtr userfactory = new UserFactory(manager);
communicator->addObjectFactory(userfactory,"::NW::Users::User");
Freeze::EvictorPtr evictor =Freeze::createEvictor(_adapter,name,"users",0,indices);
_adapter->addServantLocator(evictor,"users");
manager->SetEvictor(evictor);
_adapter->add(manager,Ice::stringToIdentity("UserManager"));
_adapter->activate();
}
virtual void
stop()
{
_adapter->deactivate();
}
private:
Ice::ObjectAdapterPtr _adapter;
};
}
}
UserManagerI.cpp:
UserManagerI::UserManagerI(const IdIndexPtr& idIndex,
const Ice::ObjectAdapterPtr& adapter)
{
_adapter = adapter;
_index =idIndex;
}
UserPrx UserManagerI::AddUser(const string& user,const string& passwd,
OperatorType optype,const Ice::Current&)
{
try
{
cout << "start adduser!" << endl;
vector<Ice::Identity> identities;
identities =_index->find(user);
if(identities.size()!=0)
{
cout << user << " exist! " << endl;
throw new UserExistException();
}
Ice::Identity ident ;
ident.category ="users";
ident.name =IceUtil::generateUUID();
UserIPtr userI = new UserI(this,user,passwd,optype);
cout <<"1!" <<endl;
_evictor->add(userI,ident);
return UserPrx::uncheckedCast(_adapter->createProxy(ident));

}
catch(DatabaseException ex)
{
cout << "Database inner error!" << endl;
DatabaseException e;
e.reason = ex.reason;
throw e;
}
I create UserManagerPrx in SessionService,like this :
UserManagerPrx usermanager =UserManagerPrx::checkedCast(ic->stringToProxy("UserManager")); then return usermanager to client,
when client run
"UserPrx user = _usermanager->AddUser(userid,passwd,OpType);"
protocal trace return "object not exist",like this:

[ Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 62
request id = 9
identity = UserManager
facet =
operation = AddUser
mode = 0 (normal)
context = ]
[ Protocol: received reply
message type = 2 (reply)
compression status = 0 (not compressed; do not compress response, if any)
message size = 41
request id = 9
reply status = 2 (object not exist)
identity = UserManager
facet =
operation = AddUser ]
E

my chatapp.xml snippet:
<icebox id="UserManager" exe="icebox" activation="on-demand">
<service name="UserManager" entry="Users:create">
<dbenv name="${service}"/>
<adapter name="UserManager" endpoints="tcp -h 127.0.0.1">
<object identity="UserManager" type="::NW::Users::UserManager"/>
</adapter>
</service>
</icebox>
I run icegridadmin,object list,UserManager exist!,what is problem?
who can give me a hand?


regards!
ewiniar

Comments

  • object not exist!

    I run icegridadmin command,
    >>> object describe UserManager
    proxy = `UserManager -t @ UserManager.UserManager.UserManager'
    type = `::NW::Users::UserManager'

    my config.icegrid config Ice.Default.Locator:
    Ice.Default.Locator=NwIceGrid/Locator:default -p 12000

    my chatapp.xml snippet

    <node name ="Chat">
    Ice.Default.Locator=NwIceGrid/Locator:default -p 12000
    <server-instance template="Glacier2"
    client-endpoints="ssl -h 10.5.0.1 -p 10005"
    server-endpoints="tcp -h 127.0.0.1"
    instance-name="Glacier2"
    session-timeout="30"
    permissions-verifier="verifier"
    session-manager="ChatSessionManager"
    add-user-to-allow-categories="2"
    client-sleep-time="500"
    server-sleep-time="500"
    ssl-plugin="IceSSL:create"
    ssl-client-cert-path="../certs"
    ssl-client-config="sslconfig.xml"
    ssl-server-cert-path="../certs"
    ssl-server-config="sslconfig.xml"
    />
    <icebox id="UserManager" exe="icebox" activation="on-demand">
    <service name="UserManager" entry="Users:create">
    <dbenv name="${service}"/>
    <adapter name="UserManager" endpoints="tcp -h 127.0.0.1">
    <object identity="UserManager" type="::NW::Users::UserManager"/>
    </adapter>
    </service>
    </icebox>

    </node>
  • Ice::ConnectionLostException

    I debug it,snippet:
    Breakpoint 3, NwCom::AddUser (this=0x901dab8, userid=@0xbf997e3c, passwd=@0xbf997e34,
    OpType=NW::Users::Administrator) at src/NwCom.cpp:36
    36 UserPrx user = _usermanager->AddUser(userid,passwd,OpType);
    (gdb) s
    IceUtil::HandleBase<IceProxy::NW::Users::UserManager>::operator-> (this=0x901dabc)
    at /usr/include/IceUtil/Handle.h:37
    37 if(!_ptr)
    (gdb) p _ptr
    $1 = (class IceProxy::NW::Users::UserManager *) 0x90490b0
    (gdb) n
    warning: connection exception:
    SslTransceiver.cpp:336: Ice::ConnectionLostException:
    connection lost: recv() returned zero
    local address = 10.5.0.1:56541
    remote address = 10.5.0.1:10005
    [ Network: closing ssl connection
    local address = 10.5.0.1:56541
    remote address = <not connected> ]
    42 return _ptr;

    I search ConnectionLostException in forum ,Server return _usermanager to client ,I try to set "_usermanager->ice_router();",but error always is these :
    warning: connection exception:
    SslTransceiver.cpp:336: Ice::ConnectionLostException:
    connection lost: recv() returned zero
    local address = 10.5.0.1:56541
    remote address = 10.5.0.1:10005
    [ Network: closing ssl connection
    local address = 10.5.0.1:56541
    remote address = <not connected> ]

    why?
  • matthew
    matthew NL, Canada
    Its very hard to follow what is going on from your posts. Could you post the example as a complete compilable archive? Then we can take a look at it.
  • example

    This is a example,please take a look at it,thanks!
    maybe it can't compile,but it should explain code's meaning,;)
  • Ice::ConnectionLostException

    Could anybody explain it for me ? Thanks!
  • benoit
    benoit Rennes, France
    Hi,

    The Ice::ConnectionLostException exception means that the connection with the server was lost. Since your client is connecting through Glacier2, the most likely reason is that Glacier2 rejected the request and closed the connection. I can't see anything obviously wrong with your code and configuration but I might have missed something.

    Could you enable tracing on the Glacier2 router with the properties below? This might give us some clues on why you get this exception.
    • Glacier2.Trace.Session=1
    • Glacier2.Client.Trace.Reject=1

    Benoit.
  • Glacier2: rejecting request

    I enable tracing on the Glacier2 router ,it report:
    [ Glacier2: Glacier2: created session
    user-id = Operator
    category = 5W>2dhNc^nTD_]at/jID
    local address = 10.5.0.1:10005
    remote address = 10.5.0.1:42282 ]

    [ Glacier2: Glacier2: rejecting request
    identity: UserManager ]
    [ Glacier2: Glacier2: expiring session
    user-id = Operator
    category = 5W>2dhNc^nTD_]at/jID
    local address = 10.5.0.1:10005
    remote address = 10.5.0.1:42282 ]
    Protocal tracer report:
    [ Protocol: sending request
    message type = 0 (request)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 62
    request id = 9
    identity = UserManager
    facet =
    operation = AddUser
    mode = 0 (normal)
    context = ]
    [ Protocol: received reply
    message type = 2 (reply)
    compression status = 0 (not compressed; do not compress response, if any)
    message size = 41
    request id = 9
    reply status = 2 (object not exist)
    identity = UserManager
    facet =
    operation = AddUser ]
    E
    icegridadmin report:
    >>> object list
    FwSession-FwSessionManager
    FwSession-verifier
    UserManager
    NwIceGrid/Admin
    NwIceGrid/Query
    NwIceGrid/SessionManager
    >>> object describe "UserManager"
    proxy = `UserManager -t @ UserManager.UserManager.UserManager'
    type = `::NW::Users::UserManager'
    >>>

    In Ice-3.0.1 manual,It says:
    If a server returns a proxy as the result of an operation, that proxy contains the server’s endpoints in the private network, as usual. (Remember, the server is unaware of Glacier2’s presence, and therefore assumes that the proxy is usable by the client that requested it.) Of course, those endpoints are not accessible to the client and, in the absence of a router, the client would receive an exception if it were to use the proxy. When that proxy is configured with a router, however, the client ignores the server’s endpoints and only sends requests to the router’s client endpoints.

    In my program,I return a proxy to client from server,If I should do some differrent work in my client?
  • benoit
    benoit Rennes, France
    Ok, from the traces, it's clear that Glacier2 rejects the request to the object with the identity "UserManager". That's because you have configured the Glacier2 router to only allow requests to objects with the category "_<user id>" by setting the Glacier2.AddUserToAllowCategories property to 2 (see the Ice manual for more information on this property).

    So either you should set this property to 0 but then clients will be able to invoke on any objects or change the category of the "UserManager" object and configure Glacier2 to allow invocations on objects with this category (see the documentation of the Glacier2.AllowCategories property for more information).

    Cheers,
    Benoit.
  • It works!

    Thanks Benoit,thanks a lot ,you are right,I neglect the Glacier2.AddUserToAllowCategories property ,
    I set the property to 0,It works well,
    thanks again!


    Regards

    ewiniar