Improved the reponse of the listen loop when an error occurs, particularly if the connection with the server is lost