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

Which http-proxy-agent package do you use? #123

Open
XiaoxiaYao opened this issue Oct 9, 2023 · 5 comments
Open

Which http-proxy-agent package do you use? #123

XiaoxiaYao opened this issue Oct 9, 2023 · 5 comments

Comments

@XiaoxiaYao
Copy link

XiaoxiaYao commented Oct 9, 2023

Привет, I could not find createHttpProxyAgent in the package. Which lib are you using?

I am using HttpProxyAgent for now. But the generated agent seems not working with your lib. Your lib is using an old agent somehow.
image

vitalets added a commit that referenced this issue Oct 9, 2023
@vitalets
Copy link
Owner

vitalets commented Oct 9, 2023

Hi! I was using http-proxy-agent 5.x where createHttpProxyAgent was defined. Now updated examples and readme for using 7.x with HttpProxyAgent class.
Thank you!

@vitalets vitalets closed this as completed Oct 9, 2023
@XiaoxiaYao
Copy link
Author

Is the proxy working for you? I use the same code. But it seems like the lib is not using the proxy ip, it's using my local ip.

@vitalets
Copy link
Owner

vitalets commented Oct 9, 2023

Is the proxy working for you? I use the same code. But it seems like the lib is not using the proxy ip, it's using my local ip.

Yes, works for me. Could you try this?

$ npx ts-node-esm examples/with-proxy.ts 163.53.18.119:80
Using proxy: 163.53.18.119:80
Translating: Ich muss Deutsch lernen!
Result: I have to learn German!

@XiaoxiaYao
Copy link
Author

Yep. I tried. Still not working. No one faces this issue besides me? 😓
image

@vitalets vitalets reopened this Oct 13, 2023
@vitalets
Copy link
Owner

Interesting. Could you try this snippet to check HttpProxyAgent in isolation?:

import { HttpProxyAgent } from 'http-proxy-agent';
import fetch from 'node-fetch';

main();

async function main() {
  console.log('without proxy');
  const res1 = await fetch('https://www.httpbin.org/ip');
  console.log(await res1.text());

  console.log('with proxy');
  const agent = new HttpProxyAgent(`http://133.18.234.13:80`); // maybe proxy needs to be replaced with fresher one
  const res2 = await fetch('https://www.httpbin.org/ip', { agent });
  console.log(await res2.text());
}

My output is:

without proxy
{
  "origin": "xx.xxx.83.147"
}

with proxy
{
  "origin": "133.18.234.13"
}

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

2 participants