2

EDIT: As has been pointed out, this code actually runs fine directly through Node -- I realise now that the problem is when I try to run it with foreman, which is part of the Heroku tool-kit. Does anyone know why I should get a different result when run with the foreman command?

I am trying to parse an XML feed using Node.js. I have code so far just to get the xml feed in chunks and output these to the console. For some reason, whenever I run it, I get an "exited with code 0" "sending SIGKILL to all processes" message at a random point (different at each run). The message comes interspersed with the last few lines of the xml (example end of output):

01:17:55 web.1  |     </item>
    01:17:55 web.1  | exited with code 0
    01:17:55 web.1  |     <item>
    01:17:55 system | sending SIGKILL to all processes
    01:17:55        |       <title>The Church of Scot
    C:\CK3\dashboard>

Does anyone know what might be causing this early exit? Here is my code

var http = require('http');
//var xml2js = require('xml2js');

var options = {
  host: 'feeds.bbci.co.uk',
  port: 80,
  path: '/news/rss.xml'
};

var req = http.get(options, function(res) {
  //console.log('STATUS: ' + res.statusCode);
  //console.log('HEADERS: ' + JSON.stringify(res.headers));
  res.setEncoding('utf8');
  res.on('data', function (chunk) {
    console.log("\n\n new chunk \n\n");
    console.log(chunk);
  });
});


req.on('error', function(e) {
  console.log('problem with request: ' + e.message);
});

req.end();  

Many thanks for your time and responses!

-Sixhobbits

user1789965
  • 43
  • 1
  • 4
  • I just tried out your code and it works fine for me. How are you executing this code? – Bill Oct 31 '12 at 23:51
  • running fine for me too, `$ node --version v0.6.12` – mrk Oct 31 '12 at 23:55
  • Thanks, Bill. Since reading your comment, I tried again, executing directly through node, and it does indeed work fine. Before, I was using the foreman command, which is part of the Heroku toolbelt [link](https://toolbelt.heroku.com/) – user1789965 Nov 01 '12 at 00:00
  • But still not sure why that should make any difference. Any ideas? – user1789965 Nov 01 '12 at 00:12
  • Maybe try to add timeout, if that is a problem? http://stackoverflow.com/questions/6214902/how-to-set-a-timeout-on-a-http-request-in-node – mvbl fst Nov 01 '12 at 01:02
  • Just tried setting timeouts of varying values -- no difference, unless I make the timeout too low, in which case I get a "problem with request: socket hang up" message. – user1789965 Nov 01 '12 at 01:19
  • Code works fine on my box. `$ node --version v0.8.10` – Menztrual Nov 01 '12 at 10:05

0 Answers0