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

tunnel compatability for proxying broken in Version 10 #1009

Closed
2 tasks done
rpappa opened this issue Dec 27, 2019 · 8 comments
Closed
2 tasks done

tunnel compatability for proxying broken in Version 10 #1009

rpappa opened this issue Dec 27, 2019 · 8 comments
Assignees
Labels
bug Something does not work as it should

Comments

@rpappa
Copy link

rpappa commented Dec 27, 2019

Describe the bug

  • Node.js version: Tested in 10.11.0 and 13.5.0
  • OS & version: Windows 10 1903

Proxying requests via the tunnel module as reccomended in the readme fail using got 10.

Actual behavior

An error is thrown:

tunnel.js:208    var hostHeader = options.request.getHeader('host');
                                     ^
TypeError: options.request.getHeader is not a function    at ...\node_modules\tunnel\lib\tunnel.js:208:38    at ClientRequest.onConnect (...\node_modules\tunnel\lib\tunnel.js:172:12)

I recognize that the error is thrown within tunnel code and not got, but as the README reccomends to use tunnel with example code provided, I think this behavior is worth opening an issue about.

Expected behavior

No error is thrown, as occurs using got 9.6.0

Code to reproduce

Replace the proxy options with a working proxy (I have tested using both Charles proxy and live proxies)

const got = require('got');
const tunnel = require('tunnel');
 
got('https://sindresorhus.com', {
    agent: tunnel.httpsOverHttp({
        proxy: {
            host: 'localhost',
            port: "8888"
        }
    })
});

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
@malsatin
Copy link

malsatin commented Jan 5, 2020

I have the same issue.

Temporary solution that I have created for myself

let https = require('https');
gotOptions.request = https.request;
gotOptions.hooks = {
    beforeRequest: [
        options => {
            options.request.getHeader = (name) => options.headers[name] || null;;
        }
    ]
};

@tobiasmuehl
Copy link
Contributor

tobiasmuehl commented Jan 5, 2020

Also have problems with this code

got('https://v4.icanhazip.com/', {
  agent: tunnel.httpsOverHttp({ proxy: { ... }),
  timeout: 5000
})

Error:

project/node_modules/tunnel/lib/tunnel.js:183
    options.request.emit('error', error);
                    ^
TypeError: options.request.emit is not a function
    at ClientRequest.onError (/project/node_modules/tunnel/lib/tunnel.js:183:21)
    at Object.onceWrapper (events.js:412:26)
    at ClientRequest.emit (events.js:305:20)
    at ClientRequest.EventEmitter.emit (domain.js:483:12)
    at Socket.socketErrorListener (_http_client.js:423:9)
    at Socket.emit (events.js:305:20)
    at Socket.EventEmitter.emit (domain.js:483:12)
    at emitErrorNT (internal/streams/destroy.js:84:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

@szmarczak szmarczak added external The issue related to an external project bug Something does not work as it should and removed external The issue related to an external project labels Jan 5, 2020
@szmarczak szmarczak self-assigned this Jan 5, 2020
@Sollunad
Copy link

Sollunad commented Jan 8, 2020

Is there any ETA for the release of this fix?

@sindresorhus
Copy link
Owner

https://github.com/sindresorhus/got/releases/tag/v10.2.2

@ash0080
Copy link

ash0080 commented Mar 31, 2020

test several packages,
tunnel, https-proxy-agent, proxy-agent and so on...

this's the only work one
https://github.com/zjael/simple-proxy-agent

and much faster, about 3 times against before. (v9.x with tunnel)

@ash0080
Copy link

ash0080 commented Apr 1, 2020

@szmarczak
I noticed that when accessing https using above one with a Local Proxy
it doesn't work, just hang up, I think maybe its because got distinguish http/https strictly, but anyway, the protocol of 'Agent' is not so clear.

For comparison purposes, I tried needle, it works well.
plz make a test if you have time.

besides, when I try to GET this url
using same proxy node, same headers, the got trigger 503 error high probability. 90% maybe,(for both v9.x v10.x)
but needle works well almost every time, so wired.
are there some "internal marks" of Got, could be detected by the Oracle's anti-robo system?

@malsatin
Copy link

malsatin commented Apr 1, 2020

test several packages,
tunnel, https-proxy-agent, proxy-agent and so on...

this's the only work one
https://github.com/zjael/simple-proxy-agent

https-proxy-agent works fine for me

@ash0080
Copy link

ash0080 commented Apr 3, 2020

test several packages,
tunnel, https-proxy-agent, proxy-agent and so on...
this's the only work one
https://github.com/zjael/simple-proxy-agent

https-proxy-agent works fine for me

Not work for me as described above,
503 error,
but needle works well, so weird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as it should
Projects
None yet
Development

No branches or pull requests

7 participants