Closed opimand closed 6 months ago
You are likely calling bot.start
. That is incorrect. You cannot run a bot with polling on serverless platforms. Instead, you have to use webhooks as explained here: https://grammy.dev/guide/deployment-types#how-to-use-webhooks
import { serve } from "https://deno.land/std@0.154.0/http/server.ts";
import { bot } from "./bot.ts";
import { webhookCallback } from "./deps.deno.ts";
const handleUpdate = webhookCallback(bot, "std/http");
serve(async (req) => {
if (req.method == "POST") {
const url = new URL(req.url);
if (url.pathname.slice(1) == bot.token) {
try {
return await handleUpdate(req);
} catch (err) {
console.error(err);
}
}
}
return new Response();
});
My code in server.ts is default with webhook, like in the example. And post request for webhook sent. And sure don't use API key somewhere second time
My answer stays the same. The screenshot confirms that you are running the bot with polling somewhere. Do you call bot.start
in bot.ts
? https://grammy.dev/resources/faq#_409-conflict-terminated-by-other-getupdates-request
Thanks for your support. You are right.
Glad It's fixed! 🎉
After deploying the bot on Deno Deploy, it works for a few hours and then requires sending an HTTP request to the webhook URL. I think this is not the behavior we expect.