desmondmorris / node-twitter

Client library for the Twitter REST and Streaming API's.
https://www.npmjs.com/package/twitter
MIT License
1.27k stars 237 forks source link

Problem in Streaming API behind proxy #79

Open prashantgbhangre opened 9 years ago

prashantgbhangre commented 9 years ago

Hello Guys.

i am troubling in one issue from last 2 week. kindly some one help me to get out from these issue.

i want to use streaming on linux server under corporate proxy.

When i use following code for get favorate it will work fine

      var Twitter = require('../lib/twitter');

      var client = new Twitter({
        consumer_key: process.env.TWITTER_CONSUMER_KEY,
        consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
        access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
        access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
        request_options: {
          proxy: 'http://myproxyserver.com:1234'
        }
      });

      /**
       * Grab a list of favorited tweets
       **/
      client.get('favorites/list', function(error, tweets, response){
        if (!error) {
          console.log(tweets);
        }
      });

but when i replace get to stream it will get error ( Error 401 unauthorized ) i make sure my all keys and proxy is correct. following code i use.

      var Twitter = require('../lib/twitter');

      var client = new Twitter({
        consumer_key: process.env.TWITTER_CONSUMER_KEY,
        consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
        access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
        access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
        request_options: {
          proxy: 'http://myproxyserver.com:1234'
        }
      });

      /*
            Streaming "Mongo".
      */
        client.stream('statuses/filter', {track: 'mango'}, function(stream) {     
            stream.on('data', function(tweet) {
              console.log(tweet.text);
            });
          });

My server Time is also correct . Thanks in advance.

CodeOtter commented 7 years ago

I'm getting the same problem under these same conditions running this in an Ubuntu 16.04 guest in Virtualbox on a OSX host.