N
N
NIK_NIKITA2020-03-11 16:02:50
Python
NIK_NIKITA, 2020-03-11 16:02:50

Guys I'm doing an echo bot in python got an error?

Error 2020-03-11 16:00:38,854 (util.py:66 PollingThread) ERROR - TeleBot: "ConnectTimeout occurred, args=(MaxRetryError("HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1142139382:AAF3-PeLf7Ct6Or7YnMyVOgzs0J2mHhoDBM/getUpdates?offset=1&timeout=20 (Caused by ConnectTimeoutError(, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))")),)
Traceback (most recent call last):
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 156, in _new_conn
conn = connection .create_connection(
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 84,in create_connection
raise err
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection
sock.connect(sa)
socket.timeout : timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3 \connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py" , line 376, in _make_request
self._validate_conn(conn)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 994, in _validate_conn
conn.connect()
File "C:\Users \ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 300, in connect
conn = self._new_conn()
File "C:\Users\ADMIN\AppData \Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 161, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (, 'Connection to api.telegram.org timed out .(connect timeout=3.5)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\ Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "C:\Users\ADMIN\AppData \Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1142139382:AAF3-PeLf7Ct6Or7YnMyVOgzs0J2mHhoDBM/getUpdates?offset=1&timeout=20 (Caused by ConnectTimeoutError(, ' Connection to api.telegram.org timed out.(connect timeout=3.5)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\ADMIN\AppData\Local \Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 60, in run
task(*args, **kwargs)
File "C:\Users\ADMIN\AppData\Local\Programs \Python\Python38-32\lib\site-packages\telebot\__init__.py", line 279, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 249, in get_updates
json_updates = apihelper.get_updates(self.token, offset , limit, timeout, allowed_updates)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 194, in get_updates
return _make_request(token , method_url, params=payload)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 57, in _make_request
result = _get_req_session( ).request(method, request_url, params=params, files=files,
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py",line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 504, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1142139382:AAF3-PeLf7Ct6Or7YnMyVOgzs0J2mHhoDBM/getUpdates?offset =1&timeout=20 (Caused by

ConnectTimeoutError (, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))

# -*- coding: utf-8 -*-
import config
import telebot

bot = telebot.TeleBot(config.token)

@bot.message_handler(content_types=["text"])
def repeat_all_messages(message): # Название функции не играет никакой роли, в принципе
    bot.send_message(message.chat.id, message.text)

if __name__ == '__main__':
     bot.infinity_polling()

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
Igor, 2020-03-11
@DMGarikk

And what confuses you in this error? there it is written in English in white (black) that there is no connection with api.telegram, which is logical given the efforts of the RKN

N
NIK_NIKITA, 2020-03-11
@NIK_NIKITA

I understand that I'm stupid but how to fix the error?
And is there any way to fix this?

A
Alexander, 2020-03-11
@AlexMine

Look in the direction of vpn, proxy, I recently use the connection via tor in development, usually you only need to add a couple of lines of code there.

Y
Yan White, 2020-03-11
@YanWhite1017

Install vpn on pc. But such that it is not English, England also has some kind of graters with a cart.

T
timur_kadirbergenov, 2020-11-24
@timur_kadirbergenov

Use:
bot.polling(none_stop = True)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question