title: Node.js socket hang up error when connecting to twitter api
body: <p>I'm getting <code>socket hang up</code> error , when connecting to twitter streaming api with basic authentication using https. I think the error is occurring when doing the authentication.</p>
  
  <pre><code>var https = require("https");
  var options = {
          host: 'stream.twitter.com',
          path: '/1.1/statuses/filter.json?track=bieber',
          method: 'GET',
          headers: {
                  "Authorization": "Basic " + new Buffer('UserName' + ":" + 'Password').toString("base64")
          }
  }; //end of options
  
  
  var request = https.request(options, function(response){
              var body = '';
               console.log('STATUS: ' + response.statusCode);
               console.log('HEADERS: ' + JSON.stringify(response.headers));
  
              response.on("data", function(chunk){
                      var tweet = JSON.parse(chunk);
                      console.log("Tweet " + tweet.text);
              });  // end of data
  
              response.on("end", function(){
                  console.log("Disconnected!!");
              }); // end of end
  
              response.on("error", function(){
                  console.log("error occured");
              }); // end of error
  }); // end of request
  
  request.on("error",function(error){
          console.log("Error: " + error.message);
                  }); // end of error
  </code></pre>
  
  <p>When i try to access this url it works fine.</p>
  
  <pre><code>https://username:password@stream.twitter.com/1.1/statuses/filter.json?track=twitter
  </code></pre>