Sorry for the delayed response.
The issue actually happens outside readConnectionMessage. Your code was already nearly perfect. But why did it hang? @vyivrain
Because the code didn’t try to read the second ping after sending back the first pong.
To continue reading pings, wrap a for loop around the read-eval-write logic:
func handleConnection(conn net.Conn) {
defer conn.Close()
for {
read
eval
write
}
}