     _onLogin: (data, headers) =>
         if data
             if not data.id
+                @logger.error 'Login call failed'
                 @authenticated = false
+                @_reconnecting = false
                 @reconnect()
             else
                 @authenticated = true

        @_messageID = 0
        @_pending = {}
        @_pingInterval = if @options.pingInterval? then @options.pingInterval else defaultPingInterval

        @_connAttempts  = 0


            @emit 'error', error

        @ws.on 'open', =>
            @_connecting = false
            @_reconnecting = false
            @connected = true
            @emit 'connected'
            @_connAttempts = 0
            @_lastPong = Date.now()
            @logger.info 'Starting pinger...'
            @_pongTimeout = setInterval =>
                if not @connected
                    @logger.error 'Not connected in pongTimeout'
                    @reconnect()
                    return
                if @_lastPong? and (Date.now() - @_lastPong) > (2*@_pingInterval)
                    @logger.error "Last pong is too old: %d", (Date.now() - @_lastPong) / 1000
                    @authenticated = false
                    @connected = false
                    @reconnect()
                else
                    @logger.info 'ping'
                    @_send {"action": "ping"}
            , @_pingInterval

        @ws.on 'message', (data, flags) =>
