fix the broken pipe issue in client