fix bug in sending keepalive requests