1

Is there any common practice technique to send heartbeat message to monitor the client devices?

What I am doing currently is setup a tasktimer and polling each client device at one second interval and wait for client device's to acknowledge before incrementing the counter to poll the second device.

If there is no acknowledgement from a device, I will attempt again up to 3 tries.

Is this a good practice?

Please advise.

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mylim
  • 313
  • 4
  • 16

1 Answers1

2

TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network. Applications that do not require reliable data stream service may use the User Datagram Protocol (UDP), which provides a connectionless datagram service that emphasizes reduced latency over reliability. Ref: "wiki".

In general, if your server and clients work in:

  • wired network instead of wireless network
  • neither of them crashes

No need to implement a heartbeat.

While heartbeat/PING/keep-alive is absolute or only working way to check the connection. But how to implement a heartbeat is a good practice or best for you, depends on your use case, for example, how often the heartbeat is efficient for you? The possible reasons for the client lost connection.

More refences:

"Do I need to heartbeat to keep a TCP connection open?"

"Keep Alive TCP/IP connected sockets over the Internet - when? how? and how much?"

"TCP Dead link detection"

Rita Han
  • 9,574
  • 1
  • 11
  • 24
  • Hi @RitaHan-MSFT Thanks. I need to send heartbeat to check if the client devices is alive at the same time to retrieve the sensor data from the client devices to be updated. – mylim Oct 19 '18 at 03:35
  • @mylim Maybe you can directly to retrieve the sensor data no need the additional heartbeat, or let the client send sensor data when the server can't receive from one client then to check if this client lost connection. – Rita Han Oct 19 '18 at 05:38
  • Hi @RitaHan-MSFT if multiple clients send at the same time there will be an issue to handle the transmission? I mean based on letting the clients to send sensor data. – mylim Oct 19 '18 at 05:47
  • 1
    @mylim All clients can't send at the exact same time if you don't synchronize them explicitly. And do you agree that a good server should be scalable to handle multiple clients access simultaneously? – Rita Han Oct 19 '18 at 06:32