E
E
el-bekasto2021-10-14 13:33:50
Python
el-bekasto, 2021-10-14 13:33:50

VK api: timeout doesn't fit into C timeval what does it mean, how to fix it?

I run a simple script on vk_api python:

import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType

vk_session = vk_api.VkApi(token='TOKEN')
lp = VkLongPoll(vk_session, 123456789) #эти цифры являются айди группы, в которой запускается бот
vk = vk_session.get_api()

try:
    for event in lp.listen():
        if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.from_user:
            vk.messages.send(
                user_id=event.user_id,
                message='messezhe'
            )
except Exception as e:
    print(e)

Prints lp.listen(). Maybe it's from the library? If yes, how to fix? timeout doesn't fit into C timeval

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-10-14
@el-bekasto

The second parameter for VkLongPoll is wait (the same timeout)

class vk_api.longpoll.VkLongPoll(vk, wait=25, mode=234, preload_messages=False, group_id=None)

wait - the waiting period (as most proxy servers terminate the connection after 30 seconds, we recommend indicating wait = 25). Maximum: 90

https://vk.com/dev/using_longpoll
Why did you decide to pass the group id there?
lp = VkLongPoll(vk_session, group_id=123456789)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question