                     return
                 }
                 self.socket.headers["X-Watson-Authorization-Token"] = token
+                self.isConnecting = true
                 self.socket.connect()
             }
         }

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

    private func connectWithToken() {
        print("Connecting with token.") // TODO: debugging
        print("Retries: \(retries)") // TODO: debugging
        guard !isConnecting else {
            return
        }

        guard retries++ < maxRetries else {
            let domain = "WebSocketManager.swift"
            let code = -1
