     if !force and (hostname is @xmlrpc?.options.host)
       return
 
-    # Makes sure there is not session id left.
-    delete @sessionId
-
     @xmlrpc = $xmlrpc.createSecureClient {
       host: hostname
       port: port ? 443

          throw error

  logIn: ->
    @sessionId = @call 'session.login_with_password', @username, @password

#=====================================================================

          # Node.js seems to reuse the broken socket, so we add a small
          # delay.
          #
          # FIXME Magic number!!!
          #
          # I would like to be able to use a shorter delay but for
          # some reason, when we connect to XAPI at a given moment,
          # the connection hangs.
          $wait $sleep 5e3
          helper()

        # XAPI is sometimes reinitialized and sessions are lost.
        # We try log in again if necessary.
        when 'SESSION_INVALID'
          @logIn()
          helper()

        # Except during the login process, catch this error and try to
        # log in again.
        when 'SESSION_AUTHENTICATION_FAILED'
          throw error unless @sessionId

          @logIn()
          helper()

