You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署在Azure Web App的Telegram Bot启动超时问题求助

Telegram Bot部署Azure Web App启动超时问题

我使用Python结合Pyrogram开发了一个Telegram Bot,并部署在Azure Web App上。初始阶段Bot运行正常,但一段时间后出现停止响应的情况,Azure Web App提示未能在预期时限(website_container_start_time_limit)内启动。

日志显示运行Flask应用的Gunicorn服务器启动成功,但约10分钟后出现超时错误并终止工作进程,该循环重复30分钟后Azure Web App彻底超时,表明应用未在配置时限内响应HTTP请求。令人意外的是,超时约30分钟后,Bot未经过任何代码或配置修改就自动恢复了正常运行。

日志信息

2024-05-21T17:07:43.804Z ERROR - Container telegram-bot for site telegram-bot did not start within expected time limit. Elapsed time = 1819.1139457 sec

2024-05-21T17:07:43.838Z ERROR - Container telegram-bot-dignified-india_0_d3110031 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.

尝试过的解决方法

  • 重新部署Bot,问题未得到解决
  • 在应用设置中添加环境变量:
    • WEBSITES_CONTAINER_START_TIME_LIMIT=1800
    • WEBSITES_PORT=8080
      原本以为延长启动时限并指定端口后,Bot能有足够时间启动并处理请求,但问题依旧存在。

参考代码

from pyrogram import Client, filters

app = Client("abc_bot", api_id=api_id, api_hash=api_hash, bot_token=bot_token)

# 处理/start命令
@app.on_message(filters.command("start"))
def start_command(client, message):
    # 回复Hello
    message.reply_text("Hello!")

# 运行Bot
app.run()

内容的提问来源于stack exchange,提问作者Yeshpal Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 10:45:14