ice_getConnection - results: connection from connection cached, not actual manually closed

eshirshoveshirshov shirshovOrganization: infocartProject: maybe electronic queueMember

result ice_getConnection mayby not actuall connection.
is it bag or normal?

auto instance_prx = _communicator->propertyToProxy({});
auto connection = instance_prx->ice_getConnection();  // new connection

connection->close(::Ice::ConnectionClose::GracefullyWithWait);

// results: connection from connection cached, manually closed
connection = instance_prx->ice_getConnection(); **// fail results !!**

// workaround
instance_prx = _communicator->stringToProxy(instance_prx->ice_toString());
connection = instance_prx->ice_getConnection(); // new connection
Tagged:

Best Answer

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi,

    Ok it's not a bug, ice_getConnection returns the cached connection without checking its state. The closed cached connection will only be cleared once you invoke an operation on the proxy. You can disable connection caching if you want the proxy to obtain a new connection the second time.

    Cheers,
    Benoit.

Answers

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff

    Hi,

    The second call to ice_getConnection after the connection close should re-establish a new connection and succeed. Isn't this what you are observing? What do you expect?

    Cheers,
    Benoit.

  • eshirshoveshirshov shirshovOrganization: infocartProject: maybe electronic queueMember

    I see : ice_getConnection - connection from connection cached.
    Version: ice3.7.1

    connection->close(::Ice::ConnectionClose::GracefullyWithWait);
    
    // results: connection from connection cached, manually closed
    connection = instance_prx->ice_getConnection(); // no new connection. Is it BUG?
    if ()
    { // variant fixed
     instance_prx->ice_fixed(connection)->ice_ping(); // throw Ice::ConnectionManuallyClosedException
    }
    else
    {
    instance_prx->ice_ping(); // create new connection
    }
    
  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff
    Accepted Answer

    Hi,

    Ok it's not a bug, ice_getConnection returns the cached connection without checking its state. The closed cached connection will only be cleared once you invoke an operation on the proxy. You can disable connection caching if you want the proxy to obtain a new connection the second time.

    Cheers,
    Benoit.

Sign In or Register to comment.