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

proxy problem? #2471

Closed
ralyodio opened this issue Nov 26, 2016 · 4 comments
Closed

proxy problem? #2471

ralyodio opened this issue Nov 26, 2016 · 4 comments
Labels

Comments

@ralyodio
Copy link

ralyodio commented Nov 26, 2016

Unhandled rejection RequestError: Error: tunneling socket could not be established, statusCode=502

 return request(Object.assign(optons, { proxy: 'http://x.x.x.x:8888' }));

getting this error when I try to use my proxy. Proxy works fine via curl.

@mike442144
Copy link

Does it always throw this kind of error?

@ralyodio
Copy link
Author

ralyodio commented Dec 16, 2016

Yes.

'use strict';

const path = require('path');
const request = require('request-promise');
const snoowrap = require('snoowrap');
const _ = require('lodash');

class SnoowrapWithProxy extends snoowrap {
  rawRequest(options) {
    return request(Object.assign(options, {
      proxy: `http://${process.env.PROXY}`
    }));
  }
}

const r = new SnoowrapWithProxy({
  user_agent: 'my bot 1.0.0',
  client_id: process.env.REDDIT_ID,
  client_secret: process.env.REDDIT_SECRET,
  username: process.env.REDDIT_USER,
  password: process.env.REDDIT_PASS
});

r.getHot().catch(console.log);

@mike442144
Copy link

Have you tried request rather than request-promise?

@stale
Copy link

stale bot commented Nov 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 23, 2018
@stale stale bot closed this as completed Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants