When deploying my Telegram bot code on Azure App Service, the deployment is successful, and the bot starts functioning properly. However, after approximately 250 seconds, the bot abruptly stops working. Below is the relevant code snippet and the error log from the Azure App Service log stream:

from pyrogram import Client, filters

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

#Define a function to handle the /start command
@app.on_message(filters.command("start"))
def start_command(client, message):
    #Send "Hello" as a response to the /start command
    message.reply_text("Hello!")

#Run the bot
app.run()

Stream Log :

2024-02-22T10:22:55.549Z ERROR - Container final17bot_0_9baf7 for site final17bot did not start within the expected time limit. Elapsed time = 247.9341095 sec

2024-02-22T10:22:55.556Z ERROR - Container final17bot_0_9baf7 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.

2024-02-22T10:22:55.600Z INFO  - Stopping site final17bot because it failed during startup.

for the steps to deploy the bot please go through the below link :

How to deploy a Python Telegram bot on Azure?

I successfully deployed my Telegram bot on Azure App Service, where it initially functioned correctly. However, it ceased operation after approximately 250 seconds without any discernible cause. I expected the bot to remain operational post-deployment, and although the deployment was successful, the subsequent cessation of the bot's functionality was unexpected. I conducted various troubleshooting steps, including code review, examining deployment settings, and analyzing logs, but have yet to identify the root cause of the issue. My expectation was to resolve the problem and ensure uninterrupted operation of the bot on Azure App Service.

0

There are 0 best solutions below