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

Support for proxy #887

Closed
Ochir opened this issue Jun 9, 2017 · 8 comments
Closed

Support for proxy #887

Ochir opened this issue Jun 9, 2017 · 8 comments
Labels
2.x 2.0 related issues Feature Request Stale Has not received enough activity

Comments

@Ochir
Copy link

Ochir commented Jun 9, 2017

Hi,

my current company uses proxy and it is not possible now to use all features of Web3 while there is no setting for proxy.
Please, add such feature to Web3.

@jlally21
Copy link

@Ochir Were you able to find a solution to this issue?

@xuzhiping7
Copy link

I need this feature too ...

@kjsninja
Copy link

kjsninja commented Sep 3, 2018

This is also our problem and come up with an improvised solution until they give full support.
We resolved it by modifying the node_modules/xh2-cookies/dist/xml-http-request.js.
I use https-proxy-agent to add a proxy agent inside XMLHttpRequest.
Source: http://codingmiles.com/node-js-making-https-request-via-proxy/

Step 1 : Import the proxy agent

....
....
Object.defineProperty(exports, "__esModule", { value: true });
var HttpsProxyAgent = require('https-proxy-agent'); //<-- added
var http = require("http");
....
....

Step 2 : Add the new proxy agent

....
....
var _a = this._url.protocol === 'http:' ? [http, this.nodejsHttpAgent] : [https, this.nodejsHttpsAgent], hxxp = _a[0], agent = _a[1];
var requestMethod = hxxp.request.bind(hxxp);
agent = new HttpsProxyAgent(process.env.SERVER_PROXY_URL); //<-- added
....
....

WARNING : Not for production use.

I'm hoping this will be fully supported in future release.

@fergarrui
Copy link

Any news about proxy support?

@0xjjpa
Copy link

0xjjpa commented Sep 6, 2019

Hi @nivida, how's it going? A couple of questions regarding this feature request.

  1. The latest pull request trying to tackle this issue Added support for custom http agent #2980 seems to have going stale. Are you currently taking pull-requests on this feature in order to continue this issue?
  2. Seems like requestOptions support added #2979 which landed in 1.2.1 tackled this topic on web sockets. Would it be accurate to say that there's still no implementation for a HTTP proxy in web3.js as of latest?
  3. Considering the latest version is 1.2.1 and the next version in npm as 2.0.0-alpha.1, yet we have ongoing commits on the 1.x branch, when would a incoming patch/minor release be able to be scheduled/requested to sneak features like this?
  4. There had been multiple work arounds suggesting how to tackle this, but seem outdated. What would be the fastest way to land a proxy call using something like https-proxy-agent? I've noticed in Added support for custom http agent #2980 you mention nodejsSet allows to update the http and https Agent, yet it's not being read in options. Would you agree that expanding the options object passed to the HTTP provider and then doing something like this.httpAgent = options.httpProxy || this.httpAgent around line 49 would be the easiest? This is related to 1. as most likely would be the code for my PR.
  5. Finally, I can't find anything related to enhancing the providers or even passing options like transactionConfirmationBlocks to web3 in the documentation. Adding those features on creation has been more of a read-the-source-code like process. Am I looking at the wrong place when trying to answer these questions?

My current use case is having a server reaching infura via proxy. In development, the server has a free pass to reach infura, but in production we set a proxy for anonymity. I do not believe there's an easy way right now to do this over HTTP/HTTPS, but I might be wrong.

Any help here to clarify this is appreciated. Pinging @benzumbrunn who helped me with all web3 proxy topics before leaving the Swiss Alps 😢, maybe he'll find these questions interesting 👀 .

@github-actions
Copy link

github-actions bot commented Jul 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions

@github-actions github-actions bot added the Stale Has not received enough activity label Jul 4, 2020
@0xjjpa
Copy link

0xjjpa commented Jul 7, 2020

All the requested PR's had been merged and a successful usage of an httpProxy was implemented. For googlers, this was achieved passing a tunnel and a httpsOverhttp proxy to now the available httpAgent option of the constructor. This issue can now be closed.

@ryanio
Copy link
Collaborator

ryanio commented Jul 7, 2020

thanks @jjperezaguinaga!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x 2.0 related issues Feature Request Stale Has not received enough activity
Projects
None yet
Development

No branches or pull requests

8 participants