Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A heartbeat is a small message sent from a client to a server (or from a server to a client and back to the server) at periodic intervals to confirm that the client is still around and active.</p> <p>For example, if you have a Node.js app serving a chat room, and a user doesn't say anything for many minutes, there's no way to tell if they're really still connected. By sending a hearbeat at a predetermined interval (say, every 15 seconds), the client informs the server that it's still there. If it's been e.g. 20 seconds since the server's gotten a heartbeat from a client, it's likely been disconnected.</p> <p>This is necessary because you <a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination" rel="noreferrer">cannot be guaranteed a clean connection termination over TCP</a>--if a client crashes, or something else happens, you won't receive the termination packets from the client, and the server won't know that the client has disconnected. Furthermore, Socket.IO supports various other mechanisms (other than TCP sockets) to transfer data, and in these cases the client won't (or can't) send a termination message to the server.</p> <p>By default, a Socket.IO client will send a heartbeat to the server every 15 seconds (<strong>heartbeat interval</strong>), and if the server hasn't heard from the client in 20 seconds (<strong>heartbeat timeout</strong>) it will consider the client disconnected.</p> <p>I can't think of many average use cases where you probably wouldn't want to use heartbeats.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload