Home Help Center

Connection Status

rhochmuthrhochmuth Member Roland HochmuthOrganization: HPProject: RGS ✭✭
I have a client application that establishes connections to several different servers at the same time. I would like to be able to monitor the status of each connection. For example, if a connection is closed or lost I would like to be able to display the status of the connection. My client application has a single communicator.

Using a slightly modified version of the HelloWorld example program that uses Ice::Application It doesn't appear that I'm able to catch the Ice exceptions that are being generated.

In my simple test I start the Hello server. Then I start the Hello client. Then I kill the server. The following exception is created by the client:

client.exe: warning: connection exception
.\TcpTransceiver.cpp:248 Ice::ConnectionLostException:

So the socket is getting the error, logging it, and re-throwing, but it not getting unwound to my main program. My main application has the following block of code.

main(int argc, char* argv[])
clientApp app;
return app.main(argc, argv);
catch(const Ice::Exception& ex)
cerr << "main: Ice::Exception." << endl;
cerr << ex << endl;
cerr << "main: Unhandled exception." << endl;

The catch blocks are never invoked. Even if I was able to trap the exception in my main application I'm still not sure I'm going to be able to accomplish what I would like to do. There doesn't appear to be a convenient method of mapping the exception back to a proxy.

Creating a callback method/methods within Ice seems to be another possiblity, but this would imply modifying Ice source.

Do you have any suggestions on how to best approach this problem?

Regards --Roland


  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Roland,

    When you kill your server and the client-server connection is lost, the client code (your client thread) is not affected unless it's in the middle of an invocation.

    If after killing your server/connection, you try another invocation, then you should get an Ice::ConnectFailedException. If you restarted your server (or had set-up an auto-launch server with IcePack), the connection would be reestablished transparently ... the client would not notice that the connection was lost, except for this logging message.

    The logging message
    warning: connection exception
    .\TcpTransceiver.cpp:248 Ice::ConnectionLostException:
    comes from a thread in the client thread pool that monitors outgoing connections. Currently logging this message is the only action it takes when it detects that a connection is lost.

    You could monitor the connectivity to your servers by pinging them a regular intervals ... but this may not be what you want.

Sign In or Register to comment.