Fix unexpected closed socket connection