GAE - Telegram bot stops working after some period of time

410 views
Skip to first unread message

Andreas

unread,
Sep 15, 2019, 10:04:29 AM9/15/19
to golang-nuts


I uploaded a simple telegram bot to google-aplication-engine. And after uploading it works as expected some time. Then it stoped respond to request from telegram. The bot is very simple


func main() {
    bot, err := tba.NewBotAPI("apitockenhere")
    ...
    for {
        select {
        case update := <-uchan:
        ...
    }
}

If I open web application in browser (it doesnot contais any handlers so it opens nothing) then telegram bot again starts working some time and then stops.

It works as expect localy but there is probably some issues with GAE. 
How to modify the code to prevent it from stopping?

Sean Liao

unread,
Sep 15, 2019, 1:30:32 PM9/15/19
to golang-nuts
switch to using a webhook so telegram calls you through a handler

this is a limitation of GAE's request based model

Andreas

unread,
Sep 15, 2019, 3:42:04 PM9/15/19
to golang-nuts
I've already tried it but in this case telegrambot did not recieve any updates from the updates channel.
I used this reference https://github.com/go-telegram-bot-api/telegram-bot-api/wiki/Webhooks 
but instead of www.google.com:8443 I used also patternbot.appspot.com:8443.

And should I use 

go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)

or

go http.ListenAndServeTLS("patternbot.appspot.com:8443", "cert.pem", "key.pem", nil)

?

Sean Liao

unread,
Sep 16, 2019, 3:42:45 AM9/16/19
to golang-nuts
read the docs: https://core.telegram.org/bots/webhooks

you will need:
  • valid tls certs 
  • maybe open the non default ports in gcp networking/firewall or use the standard 443
Reply all
Reply to author
Forward
0 new messages