robot-mafia / nestjs-telegraf

🤖 Powerful Nest module for easy and fast creation Telegram bots
https://nestjs-telegraf.0x467.com
MIT License
509 stars 87 forks source link

409: Conflict: terminated by other getUpdates request #1238

Open llegoelkelo opened 1 month ago

llegoelkelo commented 1 month ago

How can you use nestjs-telegraf if your API is running horizontally on several containers at the same time?

As of now, I get the following error:

409: Conflict: terminated by other getUpdates request...
nakamuraos commented 2 weeks ago

I see this line in the source code: https://github.com/robot-mafia/nestjs-telegraf/blob/a94cad7a4b7b536205cb5bfb059313bec16cbc88/lib/utils/create-bot-factory.util.ts#L15

There is a chance that if you pass the option launchOptions: false to Factory, the bot will not launch (This is what causes this error):

import { CacheInterceptor, CacheModule, Module } from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { TelegrafModule } from "nestjs-telegraf";

@Module({
  imports: [
    CacheModule.register({ isGlobal: true }),
    TelegrafModule.forRoot({
      botName: "MY_BOT",
      token: "API_KEY",
      options: {
        handlerTimeout: 180000,
      },
+     launchOptions: false,
      include: [MyModule],
    }),
  ],
  providers: [
    { provide: APP_INTERCEPTOR, useClass: CacheInterceptor },
  ],
})
export class AppModule {}

However, the bot will not be able to listen for events from Telegram, only manually send message or call api.