node.js - Heroku R10 (Boot Timeout) error with Node app - but not using an HTTP server? -


i have simple node.js app hosted on heroku consumes twitter stream. works fine sometimes, when review logs, see has begun crash regularly r10 error code.

i've done deal of googling other questions on topic, like one, , consensus seems heroku requires listen process.env.port instead of explicitly setting own port. fair enough.

but i'm not setting port anywhere in code, , nor set http.createserver can .listen one. how can solve error? ideas?

here's code reference:

var config = require('./config'); var count = require('./count'); var twit = require('twit');  var t = new twit(config);  port = process.env.port;  // reference, not used anywhere  var stream = t.stream('user', {track: "@isitoveryet2016"});  stream.on('connect', function (request) {     console.log("opening twitter stream..."); });   stream.on('connected', function (response) {     console.log("connected , streaming on port: " + port); });  stream.on('tweet', function (tweet){     if (tweet.text.charat(0) == "@"){         if (tweet.user.screen_name == "isitoveryet2016") {         console.log("ignoring own reply.");         } else {         var thistweet = count.timeleft();         console.log("received direct tweet from: " + tweet.user.screen_name);         console.log("text: " + tweet.text);         t.post('statuses/update', {in_reply_to_status_id: tweet.id_str, status: "@" +          tweet.user.screen_name +          thistweet}, function (err, data, res){             if (err) return handleerror(err);             else console.log('tweet deployed!');             });         }     }     else {         console.log("not direct tweet, not replying.");     } });  stream.on('warning', function (response) {     console.log(response); });  stream.on('disconnect', function (response) {     console.log(response); });  function handleerror(err) {   console.error('response status:', err.statuscode);   console.error('data:', err.data); } 

by default, have web process that's expected listen on port 80. can change non-web process creating procfile, like:

worker: node twitter.js 

then telling heroku use worker, , not expect web process:

heroku scale web=0 worker=1 

(at least, i'm should want. it's rare apps not have web server involved somewhere)

(also: don't need process.env.port thing if don't plan on using it. don't @ code, expect web process bind $port)

disclosure: i'm node.js platform owner @ heroku.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -