Results 1 to 3 of 3

Thread: How can I catch the Ice::ConnectionLostException in bi_dir server?

  1. #1
    karl_ma is offline Registered User
    Join Date
    Sep 2005
    Posts
    6

    Talking How can I catch the Ice::ConnectionLostException in bi_dir server?

    Hello.
    To test the bi_dir. when I shutdown the communicator from client. the server will show a waring :TcpTransceiver.cpp:275: Ice:ConnectionLostException.
    I want to catch the exception in my program, so I can deal with some clean works. How can I do it?

    Thanks.
    Karl Ma
    SuperPhone(http://www.superphone.com)
    For task of evaluating ICE.

  2. #2
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    You can't catch this exception, it's catched by the Ice internals. You can disable this warning by setting the Ice.Warn.Connections property to 0.

    Even if this was possible, I wouldn't recommend relying on the closure of the network connection for the server to do some cleanup when the client goes away: this might work if you use bi-dir but this wouldn't work anymore if you decide to use Glacier2 between your server and client for example.

    A better aproach is to use explicit sessions between the server and client. Take a look at the demo/Ice/session demo and the Ice newsletters for more information on sessions.

    Benoit.

  3. #3
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    To test this I modified the bidir demo as follows:

    Code:
    class CallbackReceiverI : public CallbackReceiver
    {
    public:
    
        virtual void
        callback(Ice::Int num, const Ice::Current& c)
        {
            cout << "received callback #" << num << endl;
            if(num % 3 == 2)
            {
                cout << "Shutting down..." << endl;
                c.adapter->getCommunicator()->shutdown();
            }
        }
    };
    When I try this I get in the server:

    adding client `e61fb1c4-d757-4bb5-bf41-4a37130937a5'
    removing client `e61fb1c4-d757-4bb5-bf41-4a37130937a5':
    c:\src\vc60\stage\Ice-2.1.2\src\ice\Outgoing.cpp:415: Ice::UnknownLocalException
    :
    unknown local exception:
    c:\src\vc60\stage\Ice-2.1.2\src\ice\ConnectionFactory.cpp:446: Ice::Communicator
    DestroyedException:
    communicator object destroyed

    Which doesn't match what you are saying. What exactly are you doing? Can you provide an example that demonstrates the problem?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ACM cause Ice.ConnectionLostException
    By sgsoft in forum Help Center
    Replies: 1
    Last Post: 03-13-2011, 07:56 AM
  2. how to catch ICE exception in Qt program?
    By rolandsun in forum Help Center
    Replies: 3
    Last Post: 09-10-2010, 09:23 AM
  3. Replies: 6
    Last Post: 07-14-2010, 11:26 AM
  4. How to catch ConnectionLostConnection exception in cpp?
    By Vitaly Berov in forum Help Center
    Replies: 7
    Last Post: 02-03-2010, 03:39 AM
  5. Replies: 4
    Last Post: 12-16-2005, 06:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •