3

I wrote a telegram bot, but it go frizes sometimes, and don't answer to the messages.

How to check the state of bot automaticaly (for exmaple from another server).

I think, that I need something like heartbeat check:

  1. Send a message from non-webhook server.
  2. Catch telegram response
  3. If response not comes in reasonable time, bot is die.

But, I need telegram client on linux server to do it.

Do you have any ideas, how to check telegram bot state?

4
  • Do you use webhook? If yes, may be your script has error (like exception) and you don't response 200 status. That's may be reason for infinity loop. Some times telegram server time response was 6 seconds. We check it by munin. Also you can check last received and last sent message time for andestanding situation
    – Dmitry
    Jun 1, 2016 at 10:33
  • Yes, I use webhook for getting updates, Sometimes our server can't process request for normal time and telegram is give up Jun 1, 2016 at 10:36
  • There is a lot of tools to ping a web services. Keywords for googling: ping monitor API health check uptime tools/services/saas. Jun 2, 2016 at 9:19
  • No, it's not full solution, becouse what can I check by this tools? Our backend work well, but I need to catch the moment when telegram not trying send messages to our backend. Jun 2, 2016 at 9:34

1 Answer 1

1

You need to find out why the bot freezes, the health check is not the answer to your problem. However If you really want to implement some kind of automated health check, you need to use Telegram CLI to send requests to your own bot in fixed intervals and check for incoming messages from that CLI user. If you are experiencing problem with Telegram's webhook, try long pulling the updates using the getUpdates method. I know a few high traffic bots that use that method, Webhooks have a max amount of concurrent requests so if you just delay them for a few milliseconds, it will start accumulating delay.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.