R
R
remag72020-09-15 20:59:27
Python
remag7, 2020-09-15 20:59:27

Why does the vk api bot longpoll event take a long time to arrive?

Good afternoon. In a personal conversation with a bot, the event arrives quickly, but in a bot conversation, it takes 30 seconds before the event arrives. Everything worked well before. I did not change anything, but there was an incomprehensible delay.
import time
import vk_api
from threading import Thread
from vk_api.bot_longpoll import VkBotLongPoll
from vk_api.bot_longpoll import VkBotEventType
def start_server():
try:
vk = vk_api.VkApi(token=api_token)
long_poll = VkBotLongPoll(vk, group_id, wait=20)
for event in long_poll.listen():
print(event)
except Exception:
print("Error")
start_server()
def payTime():
time.sleep(60)
thread1 = Thread(target=payTime)
thread2 = Thread(target=start_server)
thread1.start()
thread2.start()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2020-09-15
@HemulGM

If you first figured out what longpoll is, then you would not ask such questions.
Longpool is a mechanism that works as follows: A
request is sent to the vk server, and the vk server accepts it, but does not respond immediately if there are no events, but waits either for events to appear, or up to 25 seconds.
Those. it’s like a slow Internet and the request went on for a long time so as not to send requests to the VK server every second unnecessarily.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question