 
         @ws.on 'close', (code, message) =>
             @emit 'close', code, message
+            @_connecting = false
             @connected = false
             @socketUrl = null
             if @autoReconnect


    reconnect: ->
        if @_reconnecting
            @logger.info 'Already reconnecting, skipping call.'
            return
        @_reconnecting = true
        if @_pongTimeout
            clearInterval @_pongTimeout

        @ws = new WebSocket @socketUrl, options

        @ws.on 'error', (error) =>
            @_connecting = false
            @emit 'error', error

        @ws.on 'open', =>
