benjick / meteor-telegram-bot

Telegram bot plugin for Meteor
24 stars 15 forks source link

Error 409 : " terminated by other getUpdates request;" #37

Closed Oyshoboy closed 6 years ago

Oyshoboy commented 6 years ago

Hi guys !

Here is my code ( on serverside ):

if (Meteor.isServer) {
    Meteor.startup(function() {
        // set our token
        TelegramBot.token = 'token';
        TelegramBot.start(); // start the bot
        TelegramBot.addListener('/start', function(command, username, original) {
            TelegramBot.method('sendMessage', {
                chat_id: original.chat.id,
                text: 'ahahahah',
                parse_mode: "HTML"

            });
        });
    });
} 

Here is the logs:

I20180414-16:53:05.764(0)? Error in polling: Error: failed [409] {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}
I20180414-16:53:06.768(0)? Error in polling: Error: failed [409] {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}
I20180414-16:53:07.769(0)? Error in polling: Error: failed [409] {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}
I20180414-16:53:08.771(0)? Error in polling: Error: failed [409] {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}
I20180414-16:53:09.767(0)? Error in polling: Error: failed [409] {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}
I20180414-16:53:10.789(0)? Error in polling: Error: failed [409] {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}
I20180414-16:53:11.775(0)? Error in polling: Error: failed [409] {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}

Please help!

benjick commented 6 years ago

What version of meteor?

Oyshoboy commented 6 years ago

@benjick METEOR@1.6.0.1

Oyshoboy commented 6 years ago

This error logs, display in console each second after meteor launch. Here is the screenshot: http://joxi.ru/1A5yd3DSnV4joA It's come from setInterval function I guess

aner87 commented 6 years ago

same issue here! any news?

benjick commented 6 years ago

If you're on 1.6 you can just use this: https://www.npmjs.com/package/node-telegram-bot-api

aner87 commented 6 years ago

thanks for the reply @benjick ! I was since yesterday, but then today they deprecated the Promise part and the code below, just by itself, doesn't work anymore:

const TelegramBot = require('node-telegram-bot-api');

// replace the value below with the Telegram token you receive from @BotFather
const token = 'YOUR_TELEGRAM_BOT_TOKEN';

// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, {polling: true});

Since my app is pretty new I was looking for an alternative instead of get crazy with that npm...but I can see there isn't really a valid alternative out there. Can I ask you help on how to figured it out?

I understand it's totally not the topic of this thread, maybe we can switch to private or to a node-telegram-bot-api issue thread =) thank you very much

PS => the app crashes giving this error:

W20180515-21:49:59.237(2)? (STDERR) Tue, 15 May 2018 19:49:59 GMT node-telegram-bot-api deprecated Automatic enabling of cancellation of promises is deprecated.
W20180515-21:49:59.238(2)? (STDERR) In the future, you will have to enable it yourself.
W20180515-21:49:59.238(2)? (STDERR) See https://github.com/yagop/node-telegram-bot-api/issues/319. at module.js:652:30
benjick commented 6 years ago

Temporary fix : load/require() the library, as early as possible, before using any Promises.

Can you try this?

aner87 commented 6 years ago

Thanks for you reply! I used this an hour ago, and it's working. Is it fine as well? :)

const TelegramBot = require('node-telegram-bot-api');
const Promise = require('bluebird');
  Promise.config({
    cancellation: true
  });

  const token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
  const bot = new TelegramBot(token, {polling: true});
benjick commented 6 years ago

Looks good, saw it in another example as well

ryanbraving commented 6 years ago

hi there, I really don't get how to use it with Meteor. Could you please provide a simple code to show how to use it in Meteor. Thanks