-
Notifications
You must be signed in to change notification settings - Fork 236
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
Tunnelling doesn't work in v3.1.0 #406
Comments
Hi and thanks for the detailed bug report. Would it be possible to see a small code snippet so I can reproduce the error quickly? |
Here's the code snippet:
Make sure to When I run this with Let me know how it goes, I will also try and debug though I am not very familiar with the codebase of |
Let me add a bit more context and details. What we are trying to achieve is to use needle with an HTTP/S proxy. In secure setup, HTTP clients are expected to send proxied requests for HTTPS resources through a HTTP CONNECT tunnel. As far as I understand, needle doesn't support CONNECT requests. Therefore we are using https://github.com/gajus/global-agent to patch node's http agent to provide CONNECT-capable proxy support. There's similar libraries like https://github.com/koichik/node-tunnel (deprecated) or https://github.com/TooTallNate/node-http-proxy-agent. The introduction of #382 picks up We're looking for a way to opt-out of needle picking up proxy configuration from environment variables. |
Yes, sorry. I'll make some time this week to take a look into this. :) |
During the analysis and debugging, I noticed that no consistent distinction is made between |
My test snipped: var needle = require('needle');
needle.get('https://github.com/status', function (error, response) {
if (!error && response.statusCode == 200)
console.log(response.body);
else console.log(error);
}); The results (via proxy:
For HTTPS pages, the connection goes through the tinyproxy, but the proxy tries to connect the destination via HTTP. An attempt with CURL through the tinyproxy works without problems. Some return values: error from squid
some output from node:
I cannot see how is send the CONNECT request. curl example
|
I have found a workaround for me: var { ProxyAgent } = require('proxy-agent');
var needle = require('needle');
needle.get('https://github.com/status',{ agent: new ProxyAgent(), use_proxy_from_env_var: false }, function (error, response) {
if (!error && response.statusCode == 200)
console.log(response.body);
else console.log(response);
}); |
This is a similar setting we're using needle. We're using proxy-agent or global-agent, but the earlier changes for needle to pick up the env variables broke this. @tomas with |
IMHO this is open. Needle supports:
And that is not the case. There is no support for |
Description
With the new version of
needle
(3.1.0) the current approach (here) to set up tunnelling doesn't work anymore (version 3.0.0 works fine). Scanning the network using Wireshark shows thatneedle
ends up loopingCONNECT
requests to the proxy. I suspect thatneedle
tries to use both thetunnel
agent while also passing proxy parameters from the environment (HTTP_PROXY
andHTTPS_PROXY
) and thus ends up in this weird state.We were previously using global agent together with
_PROXY
environment variables to forceneedle
to doCONNECT
requests but since the new version that also doesn't work (which might be a different issue)How to reproduce
mtimproxy
(or any other proxy)tunnel
agent as describe in the documentation, pointingproxy
andport
to themtimproxy
.HTTP_PROXY
andHTTPS_PROXY
environment variables to point to the same proxyneedle
Expected behaviour
When
HTTP_PROXY
andHTTPS_PROXY
is set, andtunnel
is configured,needle
should make aCONNECT
request to the proxy and establish a tunnelActual behaviour
needle
tries to establishCONNECT
request but doesn't succeedThe text was updated successfully, but these errors were encountered: