Reputation: 145
Error:
Connection to api.telegram.org timed out.(connect timeout=5.0)
I believe this error occur is due to lots of time pinging the same destination and reached the max. no. of hits. Before I didn't put the Proxy (REQUEST_KWARGS) to the updater at the beginning, the below proxy config. is just giving a try on that by referencing others people solution. However, no luck for me and doesn't work at all.
#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.")
How can I fix this?
Upvotes: 0
Views: 3350