Fixed keepalive_thread() to check the "keepalive" configuration