Detect disconnects and reconnect automatically