Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy support #7

Open
hgavert opened this issue Jun 4, 2012 · 12 comments
Open

Proxy support #7

hgavert opened this issue Jun 4, 2012 · 12 comments

Comments

@hgavert
Copy link

hgavert commented Jun 4, 2012

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)?

@ttezel
Copy link
Owner

ttezel commented Jun 4, 2012

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

@hgavert
Copy link
Author

hgavert commented Jun 5, 2012

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
});

@kai-koch
Copy link

kai-koch commented Dec 7, 2012

This is not yet ported to the oauth module, due to missing unit-tests and other stuff:
ciaranj/node-oauth#108

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

@webmutation
Copy link

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?

@vickykatoch
Copy link

Is there any solution to this issue?

@ttezel
Copy link
Owner

ttezel commented Jan 31, 2016

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

@pppurple
Copy link

request module following environment variables.

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

@clouedoc
Copy link

You can use proxychains instead.

@maronro
Copy link

maronro commented Oct 31, 2019

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);
})`

@edsu
Copy link

edsu commented Dec 11, 2021

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 DocNow/hydrator#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?

@clouedoc
Copy link

@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

@edsu
Copy link

edsu commented Dec 11, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants