Skip to content

Using proxy #130

Open
Open

Description

@omidn

I'm wondering if it is possible to use proxy with request-promise too as for the original request module.

here is explained how to set a proxy to tor in request, but providing the same options for request-promise seem not to be working..

Link to example

I am trying something like this now, which seem to be failed..

const response = yield rp({
            resolveWithFullResponse: true,
            uri: uri,
            agentClass: Agent,
            agentOptions: {
                socksHost: 'localhost', // Defaults to 'localhost'.
                socksPort: 9150 // Defaults to 1080.
            }
        });

I tried it again with request module and it is working..

Activity

  1. analog-nico commented on Jun 20, 2016

    @analog-nico
    Member

    Hi @omidn I see no reason why it shouldn't. Technically, Request-Promise is just calling Request with passing a callback.

    Please compare your two implementations if they are identical and if they use the same Request version. If you can't spot anything what is the error you get in the Request-Promise version?

  2. analog-nico commented on Jul 9, 2016

    @analog-nico
    Member

    Did you find something out worth sharing @omidn ?

  3. omidn commented on Jul 12, 2016

    @omidn
    Author

    @analog-nico I'm afraid not yet. I'll try to dig more and find it out.

  4. Ennelya commented on Jul 21, 2016

    @Ennelya

    I use request-promise@3.0.0 and passing proxy key-value to the options object of the request works for me, i.e:
    request.post({
    proxy: 'localhost:port',
    url: "yourUrl",
    ...etc
    } )

  5. RomanBON commented on Nov 23, 2016

    @RomanBON

    Hello, people! Someone solved this problem?

  6. bannerchi commented on Dec 16, 2016

    @bannerchi

    @RomanBON try like this :

    var proxyUrl = "http://" + user + ":" + password + "@" + host + ":" + port;
    
    var proxiedRequest = request.defaults({'proxy': proxyUrl});
    proxiedRequest.get('http://foo.bar')

    requst issues here

  7. k0pernikus commented on Jun 27, 2017

    @k0pernikus

    @bannerchi Thank you for pointing this out and I can confirm your approach is working

    I had a very hard time configuring the proxy using request/request-promise library as I expected to be able to set it via the requestOptions like:

        const options: rp.OptionsWithUri = {
            "uri": "http://some-website.com",
            "method": "GET",
            "proxy": "http://my-proxy.com:3819",
        };
        const result = await rp(options);
    

    which produced connection refused errors.

  8. heshaShawky commented on Jan 9, 2020

    @heshaShawky

    I'm getting 500 internal error with all above solutions! on postman and the console return error

    Error: tunneling socket could not be established, cause=read ECONNRESET +17663ms
    RequestError: Error: tunneling socket could not be established, cause=read ECONNRESET
        at new RequestError (/Volumes/Partion-2/Projects/cars-blog/node_modules/request-promise-core/lib/errors.js:14:15)
        at Request.plumbing.callback (/Volumes/Partion-2/Projects/cars-blog/node_modules/request-promise-core/lib/plumbing.js:87:29)
        at Request.RP$callback [as _callback] (/Volumes/Partion-2/Projects/cars-blog/node_modules/request-promise-core/lib/plumbing.js:46:31)
        at self.callback (/Volumes/Partion-2/Projects/cars-blog/node_modules/request/request.js:185:22)
        at Request.emit (events.js:189:13)
        at Request.onRequestError (/Volumes/Partion-2/Projects/cars-blog/node_modules/request/request.js:881:8)
        at ClientRequest.emit (events.js:189:13)
        at ClientRequest.onError (/Volumes/Partion-2/Projects/cars-blog/node_modules/tunnel-agent/index.js:179:21)
        at Object.onceWrapper (events.js:277:13)
        at ClientRequest.emit (events.js:189:13)
        at Socket.socketErrorListener (_http_client.js:392:9)
        at Socket.emit (events.js:189:13)
        at emitErrorNT (internal/streams/destroy.js:82:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
        at process._tickCallback (internal/process/next_tick.js:63:19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions