fix dead loop when connection broken