Node.js fetching Twitter Streaming API - EADDRNOTAVAIL

Posted by Jordan Scales on Stack Overflow See other posts from Stack Overflow or by Jordan Scales
Published on 2012-09-08T18:16:55Z Indexed on 2012/09/09 3:38 UTC
Read the original article Hit count: 347

I have the following code written in node.js to access to the Twitter Streaming API. If I curl the URL below, it works. However, I cannot get it to work with my code.

var https = require('https');

https.request('https://USERNAME:[email protected]/1.1/statuses/sample.json', function(res) {
  res.on('data', function(chunk) {
    var d = JSON.parse(chunk);
    console.log(d);
  });
});

But I receive the following

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: connect EADDRNOTAVAIL
    at errnoException (net.js:642:11)
    at connect (net.js:525:18)
    at Socket.connect (net.js:589:5)
    at Object.<anonymous> (net.js:77:12)
    at new ClientRequest (http.js:1073:25)
    at Object.request (https.js:80:10)
    at Object.<anonymous> (/Users/jordan/Projects/twitter-stream/app.js:3:7)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)

If anyone can offer an alternative solution, or explain to me why this doesn't work, I would be very grateful.

© Stack Overflow or respective owner

Related posts about node.js

Related posts about authentication