added timeout protection

Added a 40seconds timer that send empty packet to prevent connection
timeout.