node-twitter icon indicating copy to clipboard operation
node-twitter copied to clipboard

Problem in Streaming API behind proxy

Open prashantgbhangre opened this issue 9 years ago • 1 comments

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.

prashantgbhangre avatar Mar 23 '15 05:03 prashantgbhangre

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

codeotter avatar Aug 05 '17 01:08 codeotter