         configuration.headers.add(.userAgent(commonUserAgentValue))
         self.session = Session(configuration: configuration)
         clearHttpCookieStorage()
+        userNameResolvingOperationQueue.maxConcurrentOperationCount = 1
     }
 }
 

    private var messageSocketPingTimer: Timer?

    // Usernames
    private var cachedUserNames = [String: String]()

    init() {

            completion(cachedUsername)
            return
        }
        userNameResolvingOperationQueue.addOperation { [weak self] in
            guard let me = self else { return }
            // 1. Again, chech if the user name is resolved in previous operation.
            if let cachedUsername = me.cachedUserNames[userId] {
                completion(cachedUsername)
                return
            }

            // 2.Ok, there's no cached one, request user page synchronously, NOT async.
            let url = userPageUrl + String(userId)
            me.session.request(url).syncResponseData {
                switch $0.result {
                case .success(let data):
                    let username = self?.extractUsername(fromHtmlData: data)
                    me.cachedUserNames[userId] = username
                    completion(username)
                case .failure(_):
                    log.error("error in resolving username")
                    completion(nil)
                }
            }
        }
    }
