Closed ThatDNS closed 6 years ago
Please tell me how to solve this issue and successfully deploy this bot on Heroku. @AlcaDesign @Schmoopiie . Thanks a lot!
If I don't change the PORT and let it be default port 80 meaning my "options" variable would look like this -
var options = {
options: {
debug: true
},
connection: {
reconnect: true
},
identity: {
username: "testdns",
password: process.env.OAUTH_TOKEN
},
channels: [userChannel]
};
If I then try to deploy on Heroku, then these are the Heroku logs -
2018-05-16T07:58:17.058946+00:00 heroku[web.1]: Starting process with command `npm start`
2018-05-16T07:58:20.247479+00:00 app[web.1]:
2018-05-16T07:58:20.247506+00:00 app[web.1]: > susi_twitchbot@1.0.0 start /app
2018-05-16T07:58:20.247508+00:00 app[web.1]: > node app.js
2018-05-16T07:58:20.247509+00:00 app[web.1]:
2018-05-16T07:58:21.049407+00:00 app[web.1]: [07:58] info: Connecting to irc-ws.chat.twitch.tv on port 80..
2018-05-16T07:58:21.050056+00:00 app[web.1]: [07:58] info: Sending authentication to server..
2018-05-16T07:58:21.187016+00:00 app[web.1]: [07:58] info: Connected to server.
2018-05-16T07:58:21.187849+00:00 app[web.1]: Heroku port: 47622
2018-05-16T07:58:21.187953+00:00 app[web.1]: App port: 80
2018-05-16T07:58:21.190821+00:00 app[web.1]: [07:58] info: [#dns4044] *<testdns>: Welcome, I'm an echo bot.
2018-05-16T07:59:17.278362+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-05-16T07:59:17.278468+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-05-16T07:59:17.421805+00:00 heroku[web.1]: Process exited with status 137
2018-05-16T07:59:17.494698+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-16T07:59:17.497126+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-16T07:59:20.767032+00:00 heroku[web.1]: Starting process with command `npm start`
2018-05-16T07:59:24.063022+00:00 app[web.1]:
2018-05-16T07:59:24.063062+00:00 app[web.1]: > susi_twitchbot@1.0.0 start /app
2018-05-16T07:59:24.063064+00:00 app[web.1]: > node app.js
2018-05-16T07:59:24.063066+00:00 app[web.1]:
2018-05-16T07:59:26.335950+00:00 app[web.1]: [07:59] info: Connecting to irc-ws.chat.twitch.tv on port 80..
2018-05-16T07:59:26.336974+00:00 app[web.1]: [07:59] info: Sending authentication to server..
2018-05-16T07:59:26.484108+00:00 app[web.1]: [07:59] info: Connected to server.
2018-05-16T07:59:26.494716+00:00 app[web.1]: Heroku port: 13393
2018-05-16T07:59:26.496102+00:00 app[web.1]: App port: 80
2018-05-16T07:59:26.510634+00:00 app[web.1]: [07:59] info: [#dns4044] *<testdns>: Welcome, I'm an echo bot.
2018-05-16T08:00:20.833032+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-05-16T08:00:20.833276+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-05-16T08:00:20.966083+00:00 heroku[web.1]: Process exited with status 137
2018-05-16T08:00:20.993822+00:00 heroku[web.1]: State changed from starting to crashed
It's solved!
I added express
module and used it to listen to the port provided by Heroku.
Basically added these lines to my source code. 😄
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`listening on ${port}`);
});
Actual behaviour:
I've made a simple echo bot for twitch. Here is the source code -
I set port to
process.env.PORT || 80
so that it uses the PORT specified by Heroku instead of using default port 80 but the app doesn't even connect. I'm able to deploy the app perfectly on local machine after setting oauth token and channel name (config variables of Heroku).Expected behaviour:
The app should use PORT given by Heroku and connect.
Heroku Error log:
Server configuration