Fix bug with connection is too early closed