benjick / meteor-telegram-bot

Telegram bot plugin for Meteor
24 stars 15 forks source link

long polling? #6

Closed dcsan closed 8 years ago

dcsan commented 9 years ago

I noticed you're polling every sec, but they do provide a timeout parameter on the getUpdates method. https://core.telegram.org/bots/api#getupdates

i tried adding that, as according to others a ~20s period will be honored by telegram, but it didn't seem to work for me.

https://github.com/dcsan/meteor-telegram-bot/blob/longpoll/telegram-bot.js#L24

had you also tried this and gave up, just going for manually "pull" polling every 1000ms ?

assumign there's nothing special about the getUpdates method to stop it going through the same path as the other api calls.

also related - do you know if the webhook method will work with how meteor.com hosting has their HTTPS certificates - are they self-signed (and therefore telegram won't accept them)

tx

benjick commented 9 years ago

It was my plan using the long polling instead of every 1000 ms but I couldn't get it to work.

It does work with webhooks on the meteor hosting, I've tried it successfully. I might include both methods in the next version, currently working so replies can be handled better and I might throw it in there.

Gonna need to research the long polling a bit more.

dcsan commented 9 years ago

it looks like meteors HTTP.call takes a timeout param too. http://docs.meteor.com/#/full/http_call

timeout Number Maximum time in milliseconds to wait for the request before failing. There is no timeout by default.

perhaps if the response does return some data meteor is assuming that's it and returns?

I believe it's also fairly opaque in that meteor is wrapping all those http calls in fibers so they can optionally be run synchronous? that may be affecting things.

dcsan commented 9 years ago

It does work with webhooks on the meteor hosting, I've tried it successfully. I might include both methods in the next version, currently working so replies can be handled better and I might throw it in there.

I was looking in the code if you supported that but i guess not atm. would be nice to have. i've been hearing from users our messages are arriving out of order, so hopefully the webhook method would solve that a bit better.

babnik63 commented 8 years ago

Yes, webhooks seems to handle the job better. Looking forward for update. Thanks

benjick commented 8 years ago

Webhooks has the problem of only working if you have HTTPS. You might not even want a port exposed to the internet. Feel free to send a PR