Archived

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

Let che client know the status of the server

If the server change it's status,for example,crash.how let all clients know the changes?except storm,because it can't sure.

Comments

  • matthew
    matthew NL, Canada
    Do you mean how do the clients discover that the server has crashed? The simplest way to know this is the proactive approach. For example,

    - If the clients call on the server on a regular basis they'll discover that the server has disappeared when the call fails.
    - If the server calls on the client on a regular basis, and the client detects that it has not done so in the expected time interval, it can conclude that the server has gone.
  • thank you
    you mean all clients call on the server on a regular basis,that's a choice,but i think it's expensive.
    i don't know whether the server can remember all the clients,the client login in or login out.If it knows,it can sent a message to all clients when it crash
  • benoit
    benoit Rennes, France
    Hi,

    I don't think your server can notify the clients of its status in all circumstances. If it crashes or if its network link goes down, it won't be able to let the client know that it's down.

    Having the client ping the server on a regular basis is the simplest and most reliable (monitoring the network connection wouldn't really help here, see this FAQ for the reasons). You could optimize a bit the pinging to only occur if there has been no activity with the server recently if you are concerned about performances.

    How many clients are you planning to support for your server?

    Cheers,
    Benoit.
  • thank you,Benoit.
    about 30 clients connect to the server.
    clienta/clientb/clientc has connected with the server,when clientd connect to the server,how to let clienta/clientb/clientc knows che clientd login?
    when che client has connected the server,it probably connect for a very long time,for this is a monitoring systerm.
  • matthew
    matthew NL, Canada
    You can use IceStorm for your client list notifications. You must be careful, however, to do this correctly. See cpp/demo/IceStorm/counter for an example. This example monitors a counter value, but conceptually monitoring a list of connected clients is equivalent.
  • IceStorm must have a topic,and it can't receive replies from client.I mean it can't assure the message have sent to the client.
    Except the IceStorm,any methods else?
  • matthew
    matthew NL, Canada
    hisensewxz wrote: »
    IceStorm must have a topic,and it can't receive replies from client.I mean it can't assure the message have sent to the client.
    Except the IceStorm,any methods else?

    I suspect you misunderstand how things work. Assuming you choose the correct QoS, the message to the client is reliable. What you cannot do, however, is return data from the method invocation (ie: return values).

    At any rate, if you don't want to use IceStorm you can always implement your own service.
  • Thank you,matthew.
    maybe i should implement the service,because i don't want to use the topic.
    thanks!