twit icon indicating copy to clipboard operation
twit copied to clipboard

Proxy support

Open hgavert opened this issue 12 years ago • 12 comments

Hi!

Twit is very cool indeed. However, I seem to have a problem in dev environment and I should use http(s) proxies. This doesn't connect and I think it's because the system proxies are not recognized by node.js. Any chance to add support for proxies (maybe optional params through conf)?

hgavert avatar Jun 04 '12 06:06 hgavert

can you show me some code so I can get a better idea of what you're trying to do?

ttezel avatar Jun 04 '12 14:06 ttezel

Hi!

I'm really just running your example stream code. This works when I'm at home (no proxies), but when I'm at the office I'm forced to use http/https proxies. So, the stream just seems to sit there, no tweets (I'm not actually tracking "mango") coming out. No errors either. Any ideas where to look? Obviously I'm not 100% sure it's the lack of proxies, but I'm guessing so.

var Twit = require('twit'); var T = new Twit({ consumer_key: 'my_key' , consumer_secret: 'my_secret' , access_token: 'my_token' , access_token_secret: 'my_token_secret' }); // // filter the twitter public stream by the word 'mango'. // var stream = T.stream('statuses/filter', { track: 'mango' }) stream.on('tweet', function (tweet) { console.log(JSON.stringify(tweet)); //.text });

hgavert avatar Jun 05 '12 08:06 hgavert

This is not yet ported to the oauth module, due to missing unit-tests and other stuff: https://github.com/ciaranj/node-oauth/pull/108

I guess, when that is resolved one way or the other, it will make to twit then. :-)

kai-koch avatar Dec 07 '12 03:12 kai-koch

This still does not work a simple example like that behind a proxy returns

Error: connect ECONNREFUSED at errnoException (net.js:904:11) at Object.afterConnect as oncomplete

twit does not work behind a proxy?

webmutation avatar Oct 16 '14 10:10 webmutation

Is there any solution to this issue?

vickykatoch avatar Nov 04 '14 17:11 vickykatoch

Would it work for your use cases if I provided the proxy and tunnel options that request allows you to set? I can let you set those variables. See here: https://github.com/request/request#proxies

ttezel avatar Jan 31 '16 03:01 ttezel

request module following environment variables.

export HTTP_PROXY=http://proxyhost:port
export HTTPS_PROXY=https://proxyhost:port

pppurple avatar Feb 16 '16 16:02 pppurple

You can use proxychains instead.

clouedoc avatar Jun 14 '16 15:06 clouedoc

Hello all - I've have run into the similar issue of not being able to run simple code at my work due to a corporate proxy. I have searched long and far for a solution but as a 'beginner' I am confused on how to implement any of the proposed solutions. I.E. using request package, oauth, etc.

If this was my code, where would i enter the proxy information and in what manner? Is it a parameter in the config options? Any help is greatly appreciated!

`const express = require('express'); const Twit = require('twit'); const request = require('request');

var T = new Twit({consumer_key: '', consumer_secret: '', access_token: '', access_token_secret: '', timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests. strictSSL: true, // optional - requires SSL certificates to be valid.) })

T.get('search/tweets', { q: 'banana since:2019-10-22', tweet_mode: "extended", count: 3 }, function(err, data, response) { console.log(data); })`

maronro avatar Oct 31 '19 13:10 maronro

I help maintain a desktop application called Hydrator that uses twit to "hydrate" tweet ids back into JSON. It's a useful practice in the social media research community. We've run into situations where users in China, who can talk to Twitter just fine in their browser, are unable to use our app because it is not using the system wide proxy set with the https_proxy or HTTPS_PROXY environment variables https://github.com/DocNow/hydrator/issues/114.

I see that proxies have come up here before in multiple issues (this seems to be the first?). Would you consider a PR that had twit use a proxy server if one was set in the environment?

edsu avatar Dec 11 '21 13:12 edsu

@edsu did your users consider running Hydrator on a remote VPS or using a VPN?

I'm interested in knowing why Chinese users aren't using these solutions, which ensures compatibility with applications without proxy configuration support

clouedoc avatar Dec 11 '21 14:12 clouedoc

Their exact setup wasn't something that I inquired about too much, since the conversation is all public on GitHub. It was clear that they were able to use their browser but not the Hydrator app, and that https_proxy was set in the environment.

edsu avatar Dec 11 '21 14:12 edsu