zjael / simple-proxy-agent Goto Github PK
View Code? Open in Web Editor NEWSimple agent for sending HTTP and HTTPS traffic through HTTP and SOCKS proxies
License: MIT License
Simple agent for sending HTTP and HTTPS traffic through HTTP and SOCKS proxies
License: MIT License
I'm getting weird 421 error and I think it's related to simple proxy agent since after switching agent to https://github.com/TooTallNate/node-proxy-agent exact same code works fine.
Only certain webservers produce this error (github is one of them), I guess it has something to do with HTTP2 and/or SNI.
I've tried to debug it via tcpdump but I don't see any major differences between two agents in protocol..
Steps to reproduce:
const fetch = require('node-fetch')
const ProxyAgent = require('simple-proxy-agent')
const TSProxyAgent = require('https-proxy-agent');
url = 'https://raw.githubusercontent.com/imakewebthings/waypoints/master/licenses.txt'
addrProxy2 = "http://any-proxy-http-or-socks"
let agent = ProxyAgent(addrProxy2)
console.log ('421 redirect err')
fetch(url, {agent})
.then(async (resp) => {
console.log(resp)
})
.catch(err => {
console.error(err)
})
.finally(() => {
let agent2 = TSProxyAgent(addrProxy2)
console.log('200 OK with tootallnate agent:')
fetch(url, {agent: agent2})
.then(async (resp) => {
console.log(resp)
})
.catch(err => {
console.error(err)
})
})
Add proxy authentication to both http and socks proxies
And be able to pass the username and password to the agent like:
new ProxyAgent('http://user:[email protected]:8080')
Resources to get started:
HTTP Auth
SOCKS Auth
let lookup = false;
switch (this.proxy.protocol) {
case 'socks4:':
case 'socks5h:': // this line is wrong, should be 'socks5:' instead
lookup = true;
break;
}
See urllib3/urllib3#1035,
Quote: In a proxy string, socks5h:// and socks4a:// mean that the hostname is
resolved by the SOCKS server, not the client
Hi Dev,
I have an issue with this. I am not able to catch this exception in try catch block.
node:internal/process/esm_loader:108
internalBinding('errors').triggerUncaughtException(
^
false
Thrown at:
at loadESM (node:internal/process/esm_loader:108:31)
Node.js v19.0.0
This exception occurs sometimes when I connect to a faulty proxy or a proxy with wrong address.
I just want to catch this error but its not getting caught in try catch.
I am using this agent with Got request module.
Is there any workaround for solving this ?
Thanks
Regards
User
I keep getting the following error when making requests through socks proxies :
SocksClientError: An invalid destination host was provided.
My request looks like this :
const ProxyAgent = require('simple-proxy-agent');
// p is a proxy that looks like 'socks://79.xxx.xx.xxx:4153'
const res = await needle('get', 'https://google.com', {
agent: new ProxyAgent(p),
follow: 10,
response_timeout: 10000,
read_timeout: 5000,
}).catch(e => e);
Any ideas on why this could be happening ?
It seemed like I was having no issues using this project but I just noticed that it seems to fail with authenticated proxies (user:pass@ip:port). Not sure if this is a common issue but when I try doing this I receive a FetchError
message that looks like this:
"request to https://google.com/ failed, reason: Client network socket disconnected before secure TLS connection was established"
The code is ECONNRESET
. The errno is also ECONNRESET
and the type is system
. Not sure why this happens but any help fixing this issue would be greatly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.