@zxqb

VKbot, Read timed out, как обойти?

Traceback (most recent call last):
File «/usr/lib/python3.8/site-packages/urllib3/connectionpool.py», line 384, in _make_request
six.raise_from(e, None)
File «», line 2, in raise_from
File «/usr/lib/python3.8/site-packages/urllib3/connectionpool.py», line 380, in _make_request
httplib_response = conn.getresponse()
File «/usr/lib/python3.8/http/client.py», line 1322, in getresponse
response.begin()
File «/usr/lib/python3.8/http/client.py», line 303, in begin
version, status, reason = self._read_status()
File «/usr/lib/python3.8/http/client.py», line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), «iso-8859-1»)
File «/usr/lib/python3.8/socket.py», line 669, in readinto
return self._sock.recv_into(b)
File «/usr/lib/python3.8/site-packages/urllib3/contrib/pyopenssl.py», line 310, in recv_into
raise timeout(‘The read operation timed out’)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «/usr/lib/python3.8/site-packages/requests/adapters.py», line 439, in send
resp = conn.urlopen(
File «/usr/lib/python3.8/site-packages/urllib3/connectionpool.py», line 637, in urlopen
retries = retries.increment(method, url, error=e, _pool=self,
File «/usr/lib/python3.8/site-packages/urllib3/util/retry.py», line 368, in increment
raise six.reraise(type(error), error, _stacktrace)
File «/usr/lib/python3.8/site-packages/urllib3/packages/six.py», line 686, in reraise
raise value
File «/usr/lib/python3.8/site-packages/urllib3/connectionpool.py», line 597, in urlopen
httplib_response = self._make_request(conn, method, url,
File «/usr/lib/python3.8/site-packages/urllib3/connectionpool.py», line 386, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File «/usr/lib/python3.8/site-packages/urllib3/connectionpool.py», line 306, in _raise_timeout
raise ReadTimeoutError(self, url, «Read timed out. (read timeout=%s)» % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=’lp.vk.com’, port=443): Read timed out. (read timeout=35)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «/home/zxqb/botb.py», line 197, in
for event in longpoll.listen():
File «/home/zxqb/.local/lib/python3.8/site-packages/vk_api/bot_longpoll.py», line 285, in listen
for event in self.check():
File «/home/zxqb/.local/lib/python3.8/site-packages/vk_api/bot_longpoll.py», line 254, in check
response = self.session.get(
File «/usr/lib/python3.8/site-packages/requests/sessions.py», line 546, in get
return self.request(‘GET’, url, **kwargs)
File «/usr/lib/python3.8/site-packages/requests/sessions.py», line 533, in request
resp = self.send(prep, **send_kwargs)
File «/usr/lib/python3.8/site-packages/requests/sessions.py», line 646, in send
r = adapter.send(request, **kwargs)
File «/usr/lib/python3.8/site-packages/requests/adapters.py», line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host=’lp.vk.com’, port=443): Read timed out. (read timeout=35)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «/home/zxqb/botb.py», line 288, in
except (requests.exceptions.ReadTimeout, socket.timeout, urllib3.exceptions.ReadTimeoutError):
NameError: name ‘requests’ is not defined


Сам обработчик ошибок:
while True:
    try:
        for event in longpoll.listen():
            if event.type == VkBotEventType.MESSAGE_NEW:
#тут код по обработке входящих сообщений
    except (requests.exceptions.ReadTimeout, socket.timeout, urllib3.exceptions.ReadTimeoutError):
        time.sleep(1)
        print('_______Timeout______')

Собственно, пытался обойти ошибки соединения через Try и вот что получилось. Что делать?
  • Вопрос задан
  • 1450 просмотров
Решения вопроса 1
hottabxp
@hottabxp Куратор тега Python
Сначала мы жили бедно, а потом нас обокрали..
NameError: name ‘requests’ is not defined
- у вас библиотека requests импортируется в коде?
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
@zxqb Автор вопроса
Импортировал все необходимые библиотек, за 12 часов ни одной ошибки
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы