Archived

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

Connection loss detection on server side

Hello, ZeroC support team.

I have two ICE components: the one is server component and the other is client one. The client connects to server, everything is fine.
Server must manage the client component. So the client component embeds the callback on his side.
Server can manage the client component by means of the callback, it works fine. Now the task is, server must know somehow whether the client is currently connected to it and it can manage the client or not. This task is solved in the following way. When server establishes a connection with a new client, it registers this connection together with client's callback in the map. Then another server's thread will ping each connection from the map and if the ping fail, then this means that the client is disconnected and there is no opportunity to manage it, so this map entry is deleted. I suppose my logic appears to be too complex, is there an easier way on the server's side detect the fact the one of his clients disconnected?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    I recommend to take a look at Michi's "Gream Reaper" article in the issue #3 of the Connections newsletter here. This is a well-known pattern in distributed programming.

    One issue with your solution is that the server might have to ping a large number of clients if many clients are connected. And if some clients are unreachable, the ping calls might hang for a long time (unless you use AMI).

    Rather than have the server ping all the clients (which could be expensive for the server), it might be better to have the client ping the server. See the demo/Ice/session included with your Ice distribution for an example.

    Cheers,
    Benoit.
  • Hello, Benoit.

    Thank you for your help.