Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
723 stars 143 forks source link

error 409: Conflict: terminated by other long poll or webhook #131

Open chiu0602 opened 8 years ago

chiu0602 commented 8 years ago

I start the bot by 2 workers, error is shown

const tg = new Telegram.Telegram(BOT_TOKEN, {
    workers: 2,
    webAdmin: {
        port: 7777,
        host: "0.0.0.0"
    }
});

[log] Telegram Master started, 4 CPUs found, 2 workers will start

[log] WebAdmin started at 0.0.0.0:7777

[log] Telegram Worker started at 6596 PID

[log] Telegram Worker started at 8328 PID

[warn] Api error: Body: { ok: false, error_code: 409, description: 'Conflict: terminated by other long poll or webhook' }

[error] fetchUpdate TelegramApiError { _code: 409, _description: 'Conflict: terminated by other long poll or webhook' }

But if worker: 2 is set, the bot can be started.

Naltox commented 8 years ago

Hey, there is no 'worker' parameter. Check that you are not runing two bots same time. There are no relations between numbers of workers and webhooks/long pools started. Webhook/long pool alsways starts only on master process.

Naltox commented 8 years ago

Also you missed 'url' parameter for webhook

chiu0602 commented 8 years ago

I use the following code with error, but if I change to workers: 1, the code runs properly. Also, I use workers as README.md mentioned, and haven't used custom webhook.

const tg = new Telegram.Telegram(BOT_TOKEN, {
    workers: 2,
    webAdmin: {
        port: 7777,
        host: "0.0.0.0"
    }
});

btw, thanks for your great code!

Naltox commented 8 years ago

@chiu0602 Cant repeat that bug :(

jokame commented 8 years ago

I'm facing similar situation. My bot initialize with 4 workers by default, and get the same "conflict".

>npm start
> node --use_strict start.js

Starting 4 workers...
Application worker 2980 started...
Application worker 8808 started...
Application worker 4840 started...
Application worker 4492 started...
[warn]
[warn]
[warn]
Api error: Body: { ok: false,
  error_code: 409,
  description: 'Conflict: terminated by other long poll or webhook' }

Api error: Body: { ok: false,
  error_code: 409,
  description: 'Conflict: terminated by other long poll or webhook' }

Api error: Body: { ok: false,
  error_code: 409,
  description: 'Conflict: terminated by other long poll or webhook' }

And I only have one bot.

unicornist commented 7 years ago

I am facing the same problem. but since I am running manually in dev machine, when this error happens (randomly) I just instantly terminate and re-run the code, and it works. since you can not reproduce the issue to debug it yourself, the following suggestions comes to mind: it's either: there is really something left from the last time (at the bot-server or even from the telegram-server) . In this case you have to find what is not closing correctly, or wait for it to finish, before starting a new one -- or -- telegram-node-bot thinks false-positively. In this case you may want to check the code of the conflict checking logic.

Thanks a lot for your wonderful work. Cheers

kamikazechaser commented 7 years ago

Switch the port to 8443

unicornist commented 7 years ago

@kamikazechaser I think the port setting only applies to the webhook model, I didn't configure it to use webhook, and I'm getting the error for the long-polling get updates method....

WoLfulus commented 7 years ago

This is really happening. The main problem with this is that the bot doesn't even start/handle this error. It should at least retry after a while.