Archived

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

Ice::ConnectionLostException in client with callback

Having created a callback interface in a client, and attaching it to a server, I can see the Ice::ConnectionLostException in the client debug trace when the server goes away. I would like to catch this, but I dont see how. Otherwise the client is just dead.

I read the FAQ and other threads regarding Ice::ConnectionLostException, but I dont see any solution there.


thanks
Rich

Comments

  • marc
    marc Florida
    You cannot catch this exception. Perhaps this FAQ is useful to help you. (Note that a callback is just like any other call, except that client and server reverse roles, so if you read this FAQ, for your specific case, you must reverse the meaning of client and server.)
  • Marc,

    I did look at that FAQ, as I mentioned.

    What then would be the ice solution to allow the client to reattach its callback to the server once it has been restarted?

    thanks
    Rich
  • matthew
    matthew NL, Canada
    Rich,

    Please note that this is nothing Ice specific. You cannot rely on a connection closure callback to re-establish a connection back to the server for the reasons outlined in the FAQ to which Marc linked.

    Depending on the structure of your application there are multiple solutions. One possible solution is to make the callback persistent in the server. When the server comes back it starts calling back on the clients which were previously connected. This is how IceStorm works.

    If persistence is not suitable in your case you could establish a session with the server in question. Once the session goes away (which you can reliably detect) then you start to re-establish the session. If you need an example of how to do sessions check demo/Ice/session.
  • Matthew,

    I will look at sessions. It seems pretty heavy for the task at the moment.

    thanks
    Rich
  • matthew
    matthew NL, Canada
    Compared to adding persistence in the server, using a session based architecture is likely much simpler. It also makes it easy to reliably track your clients connectivity, and maintain per-session state.
  • Thanks,

    Rich