Fix bugs conection is closed