Archived
This forum has been archived. Please start a new discussion on GitHub.
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.
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.
0
Comments
-
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.0 -
To test this I modified the bidir demo as follows:
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?0