I guess when the client sends some data is through a web socket, so you can keep a map of the clients connected into the websocket and make heartbeats every 5 seconds if the heartbeat fails you remove the connection from the weboscket