@fm1ck3y

Как исправить ошибку HTTPSConnectionPool?

Здравствуйте, столкнулся с такой проблемой, после того как сменил провайдера, начались проблемы в разных requests запрос на Python. Особенно это касается ботов для Telegram и VK. Когда бот только запускается всё работает хорошо, но если ему не присылать сообщения 1-2 часа, то он выдаёт ошибку (ниже), после 2-х сообщений он продолжает работать в обычном режиме. Сразу говорю, дело не в прокси, без прокси такая же ошибка. Читал про эту ошибку на GitHub'е, там решилась проблема откатом requests до 2.10.0 , но мне это не помогло.
2019-08-26 16:42:56,357 (util.py:65 WorkerThread1) ERROR - TeleBot: "ProxyError occurred, args=(MaxRetryError("HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot823885915:AAF9xheu6j-woiV9P8u9lqGdODr7KpNyXeM/sendMessage?chat_id=-320766392&text=***иероглифы*** (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer')))"),)
Traceback (most recent call last):
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py", line 385, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py", line 578, in urlopen
    chunked=chunked)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.7/http/client.py", line 257, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.7/ssl.py", line 1052, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.7/ssl.py", line 911, in read
    return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/adapters.py", line 403, in send
    timeout=timeout
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py", line 623, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/packages/urllib3/util/retry.py", line 281, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot823885915:AAF9xheu6j-woiV9P8u9lqGdODr7KpNyXeM/sendMessage?chat_id=-320766392&text=***иероглифы*** (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/util.py", line 59, in run
    task(*args, **kwargs)
  File "handler.py", line 70, in help_command
    'Команды:\n1. "@username /добавить" - добавить задание пользователю (После этой команды действовать по инструкции) \nПример: "@fm1ck3y /добавить"\n'
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/__init__.py", line 598, in send_message
    reply_markup, parse_mode, disable_notification))
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 140, in send_message
    return _make_request(token, method_url, params=payload, method='post')
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 54, in _make_request
    timeout=(connect_timeout, read_timeout), proxies=proxy)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/adapters.py", line 465, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot823885915:AAF9xheu6j-woiV9P8u9lqGdODr7KpNyXeM/sendMessage?chat_id=-320766392&text=***иероглифы*** (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer')))
"
Traceback (most recent call last):
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/util.py", line 59, in run
    task(*args, **kwargs)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/__init__.py", line 276, in __retrieve_updates
    updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/__init__.py", line 246, in get_updates
    json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 180, in get_updates
    return _make_request(token, method_url, params=payload)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 56, in _make_request
    return _check_result(method_name, result)['result']
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 75, in _check_result
    raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}']
2019-08-26 16:43:38,612 (util.py:65 WorkerThread2) ERROR - TeleBot: "ProxyError occurred, args=(MaxRetryError("HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot823885915:AAF9xheu6j-woiV9P8u9lqGdODr7KpNyXeM/sendMessage?chat_id=-320766392&text=%D0%9A%D0%BE%D0%BC%D0%B0%D0%BD%D0%B4%D1%8B%3A%0A1.+%22%40username+%***иероглифы*** (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer')))"),)
Traceback (most recent call last):
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py", line 385, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/util.py", line 198, in or_set
    self._set()
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/util.py", line 211, in <lambda>
    e.set = lambda: or_set(e)
2019-08-26 16:52:27,391 (util.py:65 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}\']',)
Traceback (most recent call last):
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/util.py", line 59, in run
    task(*args, **kwargs)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/__init__.py", line 276, in __retrieve_updates
    updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/__init__.py", line 246, in get_updates
    json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 180, in get_updates
    return _make_request(token, method_url, params=payload)
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 56, in _make_request
    return _check_result(method_name, result)['result']
  File "/home/m1ck3y/.local/lib/python3.7/site-packages/telebot/apihelper.py", line 75, in _check_result
    raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}']
"
  • Вопрос задан
  • 2600 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Layerqa
Пишет что уже другой бот работает на этой машинe, попробуйте заюзать bot.polling(none_stop=True)
Ответ написан
Комментировать
Ваш ответ на вопрос

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

Похожие вопросы