【问题标题】:Pytelegrambotapi Throws ReadTimeout errorPytelegrambotapi 引发 ReadTimeout 错误
【发布时间】:2021-12-09 18:33:29
【问题描述】:

我目前正在使用 python/Pytelegrambotapi 开发 Telegram 机器人。
在我的本地机器中,如果机器人在没有任何请求的情况下启动并离开一段时间,它会终止并抛出错误 requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=25)

谁能帮我处理这个错误。

提前致谢

【问题讨论】:

    标签: python bots telegram telegram-bot py-telegram-bot-api


    【解决方案1】:

    有时会发生网络或电报问题。

    处理异常或使用 bot.infinity_polling() 代替 bot.polling()

    编辑:用这些参数试试这个函数(你可以在以后随意调整)

    bot.infinity_polling(timeout=10, long_polling_timeout = 5)

    【讨论】:

    • 也尝试过 bot.infinity_polling(),但结果是同一个哥们!
    • 也许可以试试 "" bot.infinity_polling(timeout=10, long_polling_timeout = 5) "" (不带引号)
    • 解决了这个问题吗?
    • 否,但问题仅在本地计算机中。托管时,一切都很好。该机器人 24/7 全天候工作
    猜你喜欢
    • 2013-11-16
    • 1970-01-01
    • 2020-09-17
    • 2019-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-09
    • 2013-11-01
    相关资源
    最近更新 更多