Sometimes the link between the server and the client can be interrupted in a way that keeps both the server and the client unaware of the broken state of the connection (e.g. when pulling the cord).
In these cases ping messages can be used as a means to verify that the remote endpoint is still responsive. Pong messages are automatically sent in response to ping messages as required by the spec.
Just like the server example above your clients might as well lose connection without knowing it. You might want to add a ping listener on your clients to prevent that.