【发布时间】:2021-08-03 13:30:07
【问题描述】:
错误:
与 api.telegram.org 的连接超时。(连接超时=5.0)
我认为发生此错误是由于大量时间 ping 同一目的地并达到最大值。不。点击数。在我一开始没有将代理(REQUEST_KWARGS)放到更新程序之前,下面的代理配置。只是通过参考其他人的解决方案来尝试一下。但是,我没有运气,根本不起作用。
#Server Start
#===========================================================
def server_start(update: telegram.Update, context: telegram.ext.CallbackContext):
context.bot.send_message(chat_id=update.message.chat_id,text=':)')
context.job_queue.run_daily(papa_BT_scan,datetime.time(hour=18, minute=30, tzinfo=pytz.timezone('Asia/Hong_Kong')),context=update.message.chat_id)
#context.job_queue.run_daily(text_w_photo2,datetime.time(hour=16, minute=51, tzinfo=pytz.timezone('Asia/Hong_Kong')),context=update.message.chat_id)
#context.job_queue.run_daily(sendPhoto_w_href,datetime.time(hour=17, minute=15, tzinfo=pytz.timezone('Asia/Hong_Kong')),context=update.message.chat_id)
#context.job_queue.run_repeating(print_current_time,15,10,context=update.message.chat_id
REQUEST_KWARGS = {'proxy_url': 'socks5h://127.0.0.1:9150' } #I have give a try by installing Tor Browser , but it doesn't work
if __name__ == "__main__":
u = Updater('<My Bot Token>', use_context=True,request_kwargs=REQUEST_KWARGS)
j = u.job_queue
dispatcher = u.dispatcher
j.set_dispatcher(dispatcher)
timer_handler = CommandHandler('start', server_start)
u.dispatcher.add_handler(timer_handler)
u.start_polling()
j.start()
print("Telegram_bot_nonFG Started.")
我该如何解决这个问题?
【问题讨论】:
标签: python proxy httprequest python-telegram-bot