Improved override of the behavior in case of expired messages.
Applications should call disconnect() if they want to close the connection.