-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Socket not emitting data when proxy fails #87
Comments
I'm seeing the same issue (with both the latest version and v2.2.3+). Here's a simple program to reproduce: const http = require('http')
const https = require('https')
const HttpsProxyAgent = require('https-proxy-agent')
const server = http.createServer()
server.on('connect', (req, socket, head) => {
console.log('proxy got request for', req.url)
socket.end('HTTP/1.1 500 Internal Server Error\r\n\r\n')
})
server.listen(() => {
const opts = {
host: 'example.com',
agent: new HttpsProxyAgent('http://localhost:' + server.address().port)
}
https.get(opts, res => {
console.log('client got response:', res.statusCode)
res.resume()
res.on('end', () => {
console.log('client detected end of response')
})
})
}) If using the latest version |
lpinca
added a commit
to lpinca/node-https-proxy-agent
that referenced
this issue
Jan 27, 2020
Allow the `'end'` event to be emitted on the `http.IncomingMessage` instance. Fixes: TooTallNate#87
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Hello guys,
I have one problem currently and a possible solution for it.
I am using
node-https-proxy-agent#3.0.1
withaxios#0.19.0
.It works properly when the proxy connects successfully. The problem comes when my proxy provider gives me an error response like
HTTP/1.1 502 Proxy Error
during the connection process. When this happens, I am unable to catch this response and then, a timeout is thrown by myaxios
instance.This is the case for all version beyond
node-https-proxy-agent#2.2.1
, the one that fixed a major security flaw. Readingaxios
code, I saw that it does not handle the closed socket properly, expecting the normal stream events to properly execute.This way, I chose to do the following:
Here a way to reproduce the problem:
Using the solution explained before, it worked. I would like to know if this is the best way to do this.
I am currently using this branch
The text was updated successfully, but these errors were encountered: