Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendMessage method has high delay time #433

Closed
SuperMasterBlasterLaser opened this issue Oct 4, 2017 · 7 comments
Closed

sendMessage method has high delay time #433

SuperMasterBlasterLaser opened this issue Oct 4, 2017 · 7 comments

Comments

@SuperMasterBlasterLaser
Copy link

SuperMasterBlasterLaser commented Oct 4, 2017

Hello.

I'm using my bot via webhooks and incoming messages from telegram are being handled by express js:

 app.post(`/bot${token}`, (req, res) => {
        bot.processUpdate(req.body);
        res.sendStatus(200);
 });

Then I'm trying to respond to telegram by using sedn message method

bot.on('message', (message) => {
      let startTime = (new Date()).getTime();
      bot.sendMessage(message.chat.id, 'Some text').then(payload => {
          let endTime = (new Date()).getTime();
          console.log(`Send time ${endTime - startTime} milliseconds`);
      });
});

My bot receives messages very fas. However, responding via sendMessage takes from 2-5 seconds.

i'm using NodeJS v.8.6.0
OS is RHEL 7
Bot is launched via PM2

My remote machine internet access works via proxy. However, it has no delay, because I have made curl requests to telegram API and it responsd very fast.

Did I miss something?

@AliSawari
Copy link

Why are you using express for handling ??

@AliSawari
Copy link

Use setWebhook instead and provide a crt.pem file with open-ssl

@SuperMasterBlasterLaser
Copy link
Author

@AliSawari using express js will provide more control of webhook endpoints.

If you wont be using express you should install Nginx, to make routing to your webhook url.

I have solved my problem regarding slow send time. It was because of proxy that is used to get access to internet. My virtual machine providers intentionally made it slow for their own reasons.

@AliSawari
Copy link

@SuperMasterBlasterLaser so now the bot is doing fine ? can I use express just like you for routing?

@SuperMasterBlasterLaser
Copy link
Author

@AliSawari Yes. Bot works fine. If you open this example you can see how express is being used for handling Telegram's data.

@AliSawari
Copy link

Thanks a lot :)

@jjhesk
Copy link

jjhesk commented Mar 5, 2018

@AliSawari @SuperMasterBlasterLaser i have done the same by running other websockets in the system and it drives the api slow. how do we resolve that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants