question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use http proxy with http puppeteer_download_host, proxy return 502.

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: puppeteer@1.14.0
  • Platform / OS version: mac OS 10.14.4 (18E226)
  • URLs (if applicable):
  • Node.js version: v8.11.3

What steps will reproduce the problem?

Please include code that reproduces the issue.

1.setup a http puppeteer_download_host in .npmrc (say: puppeteer_download_host=http://xxx.com/mirrors) 2.config http_proxy to npm: http_proxy=http://127.0.0.1:xxx 3.npm i puppeteer

What is the expected result? puppeteer download and install chrome.

What happens instead?

ERROR: Failed to download Chromium r641577! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
Error: Download failed: server returned code 502. URL: http://xxxx.com/mirrors/chromium-browser-snapshots/Mac/641577/chrome-mac.zip
    at response (/Users/unightsun/workspace/git/MobileAssistCrawler/crawl-page/MarketPageAnalysisNode/node_modules/puppeteer/lib/BrowserFetcher.js:232:21)
    at ClientRequest.requestCallback (/Users/unightsun/workspace/git/MobileAssistCrawler/crawl-page/MarketPageAnalysisNode/node_modules/puppeteer/lib/BrowserFetcher.js:288:7)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at HTTPParser.parserOnIncomingClient (_http_client.js:543:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)
    at Socket.socketOnData (_http_client.js:440:20)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
  -- ASYNC --
    at BrowserFetcher.<anonymous> (/Users/unightsun/workspace/git/MobileAssistCrawler/crawl-page/MarketPageAnalysisNode/node_modules/puppeteer/lib/helper.js:110:27)
    at Object.<anonymous> (/Users/unightsun/workspace/git/MobileAssistCrawler/crawl-page/MarketPageAnalysisNode/node_modules/puppeteer/install.js:64:16)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

I chase the code across install.js, found that puppeteer use ‘https-proxy-agent’ as default ProxyAgent, but it use 443 as it’s defaultPort: /https-proxy-agent/index.js:59:

 this.defaultPort = 443;

_http_client.js:135:

  var defaultPort = options.defaultPort ||
                    this.agent && this.agent.defaultPort;
  var port = options.port = options.port || defaultPort || 80;

/puppeteer/lib/BrowserFetcher.js:269:
function httpRequest gives neither defaultPort or port.

so proxy use 443 port for http url:

CONNECT xxx.com:443 HTTP/1.1
Host: xxx.com:443
Connection: close

I must specified port in url to make it works:

puppeteer_download_host=http://xxx.com:80/mirrors

so consider specified port in BrowserFetcher.js:273:

+++ options.port = options.port || (options.protocol === 'https:' ? 443 : 80);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
hiroppycommented, Jun 2, 2019

@aslushnikov currently, google is down. I think the cause is this. fyi https://downdetector.com/status/google

So, maybe not the same issue… sorry.

0reactions
stale[bot]commented, Jul 27, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

A 502 proxy error occurs when you try to create an HTTPS ...
When you try to create a HTTPS connection, the downstream proxy that has Forefront TMG 2010 installed forwards the HTTPS CONNECT request to...
Read more >
How To Fix a 502 Bad Gateway Error - Kinsta
“502 Proxy Error”; A blank white screen; “502 Server Error: The server encountered a temporary error and could not complete your request”; “HTTP ......
Read more >
Troubleshooting HTTP 502 bad gateway - OutSystems Support
An HTTP 502 - bad gateway server error response code indicates that the server, while acting as a gateway or proxy, received an...
Read more >
502 Bad Gateway - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, ......
Read more >
Is it correct to return a 502 status code when it's my proxy that ...
An invalid Content-Length could just as well be handled as an invalid response (502 error). 503 should only be used when the condition...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found