Charca / bootbot

Facebook Messenger Bot Framework for Node.js
MIT License
974 stars 252 forks source link

Heroku connection error = 28 #97

Closed unigazer closed 6 years ago

unigazer commented 6 years ago

Hello,

I've followed the documentation on how to build your bot, I've got a successful connection with webhook while using ngrok.

But when I try to connect the bot with Heroku, I get this error

65465456448

and can't find the related issue on Google, only for this repository jw84/messenger-bot-tutorial , but it seems that nobody has faced a similar issue. Tried to look for answers on stack overflow, without success.

I was searching for these terms on Google: curl_errno = 28 Heroku Node.js, not helpful.

This is the log from Heroku

2017-12-16T18:23:22.994689+00:00 heroku[web.1]: Process exited with status 137
2017-12-16T18:23:24.737839+00:00 heroku[web.1]: Starting process with command `node index.js`
2017-12-16T18:23:26.595486+00:00 app[web.1]: BootBot running on port 3000
2017-12-16T18:23:26.596055+00:00 app[web.1]: Facebook Webhook running on localhost:3000/webhook
2017-12-16T18:23:23.007849+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-16T18:23:23.010050+00:00 heroku[web.1]: State changed from crashed to starting
2017-12-16T18:24:15.265011+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/webhook?hub.mode=subscribe&hub.challenge=1270710795&hub.verify_token=fake_token" host=itm-bot.herokuapp.com request_id=e83b0020-c645-42bc-bf10-5ecfd1a37162 fwd="31.13.106.122" dyno= connect= service= status=503 bytes= protocol=https
2017-12-16T18:24:25.285419+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-16T18:24:25.156812+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-12-16T18:24:25.156704+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-12-16T18:24:25.271462+00:00 heroku[web.1]: Process exited with status 137

and this is the index.js

'use strict';
const BootBot = require('bootbot');

const bot = new BootBot({
    accessToken: 'FB_ACCESS_TOKEN',
    verifyToken: 'FB_VERIFY_TOKEN',
    appSecret: 'FB_APP_SECRET'
});

// Upon receiving the messsage
bot.on('message', (payload, chat) => {

    // Grab the message and the user ID
    const text = payload.message.text;
    const userId = payload.sender.id;

    // Send the text message 
    bot.say('Hello! ' + userId);
});

bot.start();

The config vars are configured properly on Heroku.

Is this a bug or did I missed something?

UPDATE

I've tried to use bootbot-cli and now when I go to http://localhost the browser says Cannot GET / and if navigate to localhost/webhook it says Forbidden though that's because of the verification token.

mraaroncruz commented 6 years ago

Instead of 'FB_ACCESS_TOKEN' you need to grab the env vars like process.env.FB_ACCESS_TOKEN if you set heroku config:set FB_ACCESS_TOKEN=yourpagetoken. Same with the other two values.

unigazer commented 6 years ago

The variables are not the problem, the problem is that the app keeps crashing. As soon as I tried with the original Facebook code, it worked upon first try. https://github.com/fbsamples/messenger-platform-samples

mraaroncruz commented 6 years ago

The link you gave is not bootbot.

Is the code you showed above the code for your bot? If it is, you are using the env vars incorrectly.

If it isn't the code for your bot, can you paste the code for your bot that instantiates the BootBot instance.

I've tried to use bootbot-cli and now when I go to http://localhost the browser says Cannot GET /

This is because the / route is not served by the webserver (express) that is created by bootbot.