         socket.onConnect = {
             print("socket did connect") // TODO: debugging
             self.operations.suspended = false
+            self.isConnecting = false
             self.retries = 0
         }
         socket.onDisconnect = { error in
             print("socket did disconnect") // TODO: debugging
             print("error: \(error)") // TODO: debugging
             self.operations.suspended = true
+            self.isConnecting = false
             if self.isAuthenticationFailure(error) {
                 print("onDisconnect calling connectWithToken()") // TODO: debugging
                 self.connectWithToken()

    private func connectWithToken() {
        print("Connecting with token.") // TODO: debugging
        print("Retries: \(retries)") // TODO: debugging
        guard retries++ < maxRetries else {
            let domain = "WebSocketManager.swift"
            let code = -1

        if let token = authStrategy.token where retries == 0 {
            print("Using token: \(token)") // TODO: debugging
            self.socket.headers["X-Watson-Authorization-Token"] = token
            isConnecting = true
            self.socket.connect()
        } else {
            authStrategy.refreshToken { error in
