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.
@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:
Here is an example how to setup Procfile Heroku config to run slack_bot.js as a background process:
worker: node slack_bot.js
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