question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Heroku Port issue

See original GitHub issue

After deployment my bot with TelegramBots java sdk on heroku, app work fine, but after 90 second it’s crashed with log: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch Heroku dynamically assigns your app a port, so you can’t set the port to a fixed number. Heroku adds the port to the env, so you can pull it from there. How i can switch listener like this (js telegram sdk): .listen(process.env.PORT || 5000) I can get port from env in java like System.getenv("PORT") but can’t find where to put it in TelegramBots sdk.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
drunckodercommented, Sep 3, 2016

@consoleassert As long as I understand, you can’t use webhook bots on heroku. A quote from https://core.telegram.org/bots/webhooks :

You’ll need a server that:

Supports IPv4, IPv6 is currently not supported for Webhooks. Accepts incoming POSTs from 149.154.167.197-233 on port 443,80,88 or 8443.

As you’ve said, heroku specifies the port for your app by itself.

So you have to use a longpolling bot.

Longpolling bot is not a WEB app on heroku, as it doesn’t listen to the incoming connections! It manually asks telegram servers wether they have a message for your bot.

So all you have to do is:

  1. Change your bot type to longpolling
  2. Change your heroku app type to worker (inside the procfile, specify it like “worker: command_to_launch” instead of “web: some_command”)
  3. Push changes to heroku
  4. Launch your bot: “heroku ps:scale worker=1”

Hope this helps you!

0reactions
rubenlaguscommented, Sep 25, 2016

@consoleassert Did @drunckoder solution work for you? If so, can you close the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Heroku + node.js error (Web process failed to bind to $PORT ...
I'm running a Discord bot on Heroku, and this threw me for a loop. Slack, Hipchat, etc. bots could likely have similar issues....
Read more >
Troubleshooting Node.js Deploys - Heroku Dev Center
Heroku apps will not bind to just any port that your app is set up with. Apps should use the Node process to...
Read more >
Heroku Help
What should I do if I'm locked out of my Heroku account? ... Select a topic, then pick a category and we'll show...
Read more >
Problem in sending e-mails through SMTP - Heroku Help
My Heroku app sends e-mails to an external SMTP server at port 25 rather than using a Heroku add-on. It seems that the...
Read more >
Runtime Principles | Heroku Dev Center
Each web process simply binds to a port, and listens for requests coming in on that port. The port to bind to is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found