Home Help Center

Connection loss detection on server side

Dima_SunDima_Sun Member Dmitry KazakovOrganization: SC "Atlas"Project: Distributed Intrusion Detection System development
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

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    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.
  • Dima_SunDima_Sun Member Dmitry KazakovOrganization: SC "Atlas"Project: Distributed Intrusion Detection System development
    Hello, Benoit.

    Thank you for your help.
Sign In or Register to comment.