Fix bug in keepalive