api.telegram超时阻断解决方法

发布时间: 2023-07-30 热度: 2373

错误:HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=25)

解决方法:

安装sudo apt install tor

sudo apt install privoxy torsocks
nano /etc/privoxy/config

pip install pysocks 

forward-socks5t / 127.0.0.1:9050 .

sudo systemctl enable privoxy.service
sudo systemctl start privoxy.service

/etc/tor/torsocks.conf

TorAddress 127.0.0.1TorPort 9050
from telebot import apihelper
apihelper.proxy = {'https': 'socks5h://127.0.0.1:9050',# 'http':'http://127.0.0.1:8118',# 'https':'https://127.0.0.1:8118'}
bot = telebot.TeleBot(TOKEN) # be sure telebot.TeleBot calls after apihelper.proxy

 

请在下方留下您的评论.加入TG吹水群