Botkit: BotKit crashes on Heroku due to port issue

Created on 17 Dec 2015  路  2Comments  路  Source: howdyai/botkit

We have a small BotKit app that runs fine on the desktop but not in Heroku, crashing with the message Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

Heroku logs:

app[web.1]: ** API CALL: https://slack.com/api/rtm.start
app[web.1]: ** No persistent storage method specified! Data may be lost when process shuts down.
app[web.1]: ** Setting up custom handlers for processing Slack messages
app[web.1]: ** BOT ID:  sandworm  ...attempting to connect to RTM!
heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
heroku[web.1]: Stopping process with SIGKILL
heroku[web.1]: State changed from starting to crashed
[web.1]: Process exited with status 137

This is our connection script:

var slackToken = process.env['TOKEN'];
var controller = Botkit.slackbot();
var bot = controller.spawn({
  token: slackToken
});

bot.startRTM(function(err,bot,payload) {
  if (err) {
    throw new Error('Could not connect to Slack');
  }
});

According to this StackOverflow post the problem is usually one of binding the app to the correct port as provided by Heroku, but we cannot find any way to do this with BotKit.

Most helpful comment

Here is an example how to setup Procfile Heroku config to run slack_bot.js as a background process:
worker: node slack_bot.js

All 2 comments

@DarrenN This is because, by default, Heroku expects your process to be a web server, and if it does not open a web port, it fails.

You can solve this in one of two ways:

  • You can tell Heroku to run this as a background process instead of a web process. This will allow it to run without listening for web traffic.
  • You can put a simple web server in y our app that does nothing (or serves a status page or something...) Botkit comes with a wrapper for the Express webserver that can be used to do this...

https://github.com/howdyai/botkit#controllersetupwebserver

Here is an example how to setup Procfile Heroku config to run slack_bot.js as a background process:
worker: node slack_bot.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheJimFactor picture TheJimFactor  路  4Comments

seriousssam picture seriousssam  路  3Comments

benbrown picture benbrown  路  3Comments

simpixelated picture simpixelated  路  3Comments

iworkforthem picture iworkforthem  路  3Comments