S
S
SanistRay2021-10-27 16:31:31
Node.js
SanistRay, 2021-10-27 16:31:31

Why does the bot crash after launch after about 1 minute?

Hello, I decided to play with bots in Telegram at my leisure.

I made a simple one from the lessons, everything works fine on the local, but when deployed to Heroku, it stops working after about a minute. Log:

2021-10-27T13:20:53.523824+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-10-27T13:20:53.973649+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-10-27T13:20:54.119848+00:00 heroku[web.1]: Process exited with status 137
2021-10-27T13:20:54.177180+00:00 heroku[web.1]: State changed from starting to crashed


I tried to add to Procfile:

web: node index.js -p $PORT

As a result, it launched with port 18119 but did not solve the problem.
I would be happy to get help from those in the know.

Bot code:

const TelegramApi = require('node-telegram-bot-api')

const token = 'ТОКЕН';

const bot = new TelegramApi(token, { polling: true })

bot.on('message', msg => {
    console.log(msg)
    const chatId = msg.chat.id;
    const text = msg.text;
    bot.sendMessage(chatId, 'Вы написали ' + text)

    if (text == '/start') {
        bot.sendMessage(chatId, "Hi, I'll text you when someone visits the site.")
    }
})


Let me summarize. The bot works correctly for the first, approximately, 60 seconds. Then an error in the log, and nothing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Story teller, 2021-10-27
@SanistRay

Try
worker: node index.js -p $PORT
https://devcenter.heroku.com/articles/background-j...
It also crashes in this mode, but it seems to restart itself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question