C
C
cepprice2018-10-07 13:07:56
Node.js
cepprice, 2018-10-07 13:07:56

Where can I set the port for Telegram bot on Heroku on Node.js?

I run the bot through

Heroku

Here is the bot code
process.env["NTBA_FIX_319"] = 1
process.env['TELEGRAM_API_TOKEN'] = '***********************************'

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


console.log('------------------------------------------------------------------------------')

const bot = new TelegramBot(process.env.TELEGRAM_API_TOKEN, {polling: true})
console.log("bot created")

I am getting an error with the command
heroku logs --tail
in logs

2018-10-07T09:56:25.925072+00:00 app[web.1]: ------------------------------ ------------------------------------------------
2018- 10-07T09:56:25.946602+00:00 app[web.1]: bot created
2018-10-07T09:57:23.441280+00:00 heroku[web.1]: State changed from starting to crashed
2018-10- 07T09:57:23.301362+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-10-07T09:57:23.301448+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-10-07T09:57:23.424562+00:00 heroku[web.1]: Process exited with status 137
2018-10-07T09:57:25.845487+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=whm-bot.herokuapp.com request_id=a401c875 -814f-477e-a9a4-799ec0c512cd fwd="178.214.254.226" dyno= connect= service= status=503 bytes= protocol=https

If I understand correctly, you need to somehow set the port.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Floydreme, 2018-10-07
@cepprice

require('https').createServer().listen(process.env.PORT || 5000).on('request', function(req, res){
  res.end('')
});

Try this code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question