Telegram bot 无法建立新连接 [WinError 10061]

问题描述

我试图写一个简单的 Telegram 机器人,但 Telegram 在我的国家受到审查 所以我使用代理来连接到电报

这是错误信息

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\utils\request.py",line 252,in _request_wrapper 
    resp = self._con_pool.request(*args,**kwargs)
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\request.py",line 68,in request
    return self.request_encode_body(method,url,fields=fields,File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\request.py",line 148,in request_encode_body
    return self.urlopen(method,**extra_kw)
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\poolmanager.py",line 
244,in urlopen
    response = conn.urlopen(method,u.request_uri,**kw)
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py",line 691,in urlopen
    return self.urlopen(method,body,headers,retries,File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py",line 665,in urlopen
    retries = retries.increment(method,error=e,_pool=self,File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\util\retry.py",line 376,in increment

raise NetworkError(f'urllib3 HTTPError {error}') from error

telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org',port=443): Max retries exceeded with url: /bot...token.../getMe (Caused by 
NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection 
object at 0x000001917CBD7760>: Failed to establish a new connection: [WinError 10061] No 
connection Could be made because the target machine actively refused it'))

这是我的代码

from telegram.ext import Updater
from telegram.ext import CommandHandler

updater = Updater("...token...")

def start(bot,update):
    chat_id = update.message.chat_id

    bot.sendMessage(chat_id=chat_id,text='connected')

start_command = CommandHandler('start',start)

updater.dispatcher.add_handler(start_command)

updater.start_polling()
updater.idle()

我应该怎么做才能得到结果?

解决方法

使用过滤器断路器,因为 Telegram 在某些国家/地区是过滤器。 另外,请勿使用 psiphon。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...