In my opinion, it's not enough to detecting the disconnection just sending ping. For example, one client was shut down suddenly, without sending closeframe or closing the connection, the server could still send message to this disconnected connection without any errors due to the tcp retransmission. Drop all outgoing packages from client side using iptables can simulate this scenario:
iptables -A OUTPUT -p tcp --sport {CLIENT_PORT} -j DROP
So it's necessary to check whether the corresponding pong was received within a certain amount of time. But this would bring more pressure to server when there are plenty of clients.
In my opinion, it's not enough to detecting the disconnection just sending ping.
For example, one client was shut down suddenly, without sending closeframe or closing the connection, the server could still send message to this disconnected connection without any errors due to the tcp retransmission. Drop all outgoing packages from client side using iptables can simulate this scenario:
So it's necessary to check whether the corresponding pong was received within a certain amount of time. But this would bring more pressure to server when there are plenty of clients.