Adding keepalive functionality