                     return
                 }
                 
-                guard let connectionInfo = getConnectionInfo() else {
-                    VK.Log.put("LongPoll", "Fail to get connection info")
-                    return
-                }
-                
-                VK.Log.put("LongPoll", "Start updating")
-                
-                let updateOperation = LongPollUpdatingOperation(
-                    server: connectionInfo.server,
-                    lpKey: connectionInfo.lpKey,
-                    startTs: connectionInfo.ts,
-                    onResponse: { updates in
-                        parse(updates)
-                    },
-                    onKeyExpired: {
-                        updateQueue.cancelAllOperations()
-                        startUpdating()
-                    }
-                )
-            
-                updateQueue.addOperation(updateOperation)
+                getConnectionInfo { connectionInfo in
+                    guard let connectionInfo = connectionInfo else {
+                        VK.Log.put("LongPoll", "Fail to get connection info")
+                        return
+                    }
+                    
+                    VK.Log.put("LongPoll", "Start updating")
+                    
+                    let updateOperation = LongPollUpdatingOperation(
+                        server: connectionInfo.server,
+                        lpKey: connectionInfo.lpKey,
+                        startTs: connectionInfo.ts,
+                        onResponse: { updates in
+                            parse(updates)
+                        },
+                        onKeyExpired: {
+                            updateQueue.cancelAllOperations()
+                            startUpdating()
+                        }
+                    )
+                    
+                    updateQueue.addOperation(updateOperation)
+                }
             }
         }
         

            
            semaphore.wait()
            
            if let result = result {
                return result
            }
            else {
                Thread.sleep(forTimeInterval: 10)
                return getConnectionInfo()
            }
        }
        
        private static func startUpdating() {

        }
        
        // swiftlint:disable:next large_tuple
        private static func getConnectionInfo(completion: @escaping ((server: String, lpKey: String, ts: String)?) -> ()) {
            guard isActive, VK.state == .authorized else {
                VK.Log.put("LongPoll", "User is not authorized")
                completion(nil)
                return
            }
            
            let semaphore = DispatchSemaphore(value: 0)
