@AlerX

Как исправить ошибку с VK API ботом?

Сталкиваюсь не первый раз с этой проблемой, закрывал глаза, но сейчас хочу решить эту проблему.
При старте бота изредка выскакивает ошибка, или в работе бота. Выдает ошибку и на vds и на локалке.
Traceback (most recent call last):
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connection.py", line 301, in connect
    conn = self._new_conn()
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x04EAD110>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.vk.com', port=443): Max retries exceeded with url: /method/stats.trackVisitor (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x04EAD110>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Bogdan/PycharmProjects/?/---.py", line 1, in <module>
    from --- import *
  File "C:\Users\Bogdan\PycharmProjects\?\---.py", line 24, in <module>
    from --- import *
  File "C:\Users\Bogdan\PycharmProjects\?\---.py", line 122, in <module>
    vk._auth_token()
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\vk_api\vk_api.py", line 209, in _auth_token
    if not reauth and self._check_token():
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\vk_api\vk_api.py", line 501, in _check_token
    self.method('stats.trackVisitor')
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\vk_api\vk_api.py", line 602, in method
    values
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Bogdan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.vk.com', port=443): Max retries exceeded with url: /method/stats.trackVisitor (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x04EAD110>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
  • Вопрос задан
  • 233 просмотра
Пригласить эксперта
Ваш ответ на вопрос

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

Войти через центр авторизации
Похожие вопросы
Level Travel Москва
До 160 000 ₽
EQWILE Казань
от 80 000 до 110 000 ₽
AGIMA Москва
от 180 000 ₽