jprichardson / jprichardson/node-google

Using Proxy

Open
#49 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
456
Forks
115
PR merge metrics
No merged PRs in 30d

Description

google.requestOptions = {
  proxy: 'http://12.41.141.10:8080',
  timeout: 30000,
  localAddress: '127.0.0.1',
  jar: true,
  headers: {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'en;q=0.5',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'DNT': 1,
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'
  }
}

If I use a proxy and some other headers, I just get this error:

Error: Error on response:Error: connect EADDRNOTAVAIL 12.41.141.10:8080 - Local (127.0.0.1:58302) : undefined
    at Request._callback (/Users/john/Work/www/myapp/node_modules/google/lib/google.js:98:16)
    at self.callback (/Users/john/Work/www/myapp/node_modules/request/request.js:186:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/Users/john/Work/www/myapp/node_modules/request/request.js:845:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
/Users/john/Work/www/myapp/scrape.js:25
  for (var i = 0; i < res.links.length; ++i) {
                         ^

TypeError: Cannot read property 'links' of null
    at /Users/john/Work/www/myapp/scrape.js:25:26
    at Request._callback (/Users/john/Work/www/myapp/node_modules/google/lib/google.js:98:7)
    at self.callback (/Users/john/Work/www/myapp/node_modules/request/request.js:186:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/Users/john/Work/www/myapp/node_modules/request/request.js:845:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the proxy request and inspect lib/google.js around the callback at line 98, along with the failing usage in scrape.js at line 25. Determine whether the reported connection error or the subsequent null response is the issue, then verify the chosen behavior with a focused reproduction or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.