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

page.goto: net::ERR_HTTP2_PROTOCOL_ERROR in headless mode #3

Open
zeropointnine0 opened this issue Nov 13, 2024 · 1 comment
Open

Comments

@zeropointnine0
Copy link

zeropointnine0 commented Nov 13, 2024

Hi,

I'm noticing that some websites are returning page.goto: net::ERR_HTTP2_PROTOCOL_ERROR error when running in headless mode, but works fine in headful mode.

Here are just a couple websites that do this:
https://disneycruise.disney.go.com
https://www.countdown.co.nz

We can use this simple example to reproduce:

import { chromium } from 'patchright';

(async () => {
  const browser = await chromium.launch({
    headless: true,
  });
  const page = await browser.newPage();

  await page.goto('https://disneycruise.disney.go.com');
})();

I suspect that they employ some anti-bot measures that are detecting this in headless mode.

Do you have any ideas or recommendations to make this work in headless mode when an HTTP2 protocol error is returned?

Thanks!

Edit:

I found that setting userAgent via context helps avoid the HTTP2 protocol error and the navigation succeeds, but once I add anything extra into the context, their Kasada kicks in and responds with 429 (even in headful mode). I've only been able to successfully use this if I don't add anything extra and use this as-is in headful mode only.

For example this worked avoid the HTTP2 error, but once on the website I get 429 response when trying to reach their login endpoint in both headless and headful:

  const context = await browser.newContext({
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  });
@Vinyzu
Copy link
Contributor

Vinyzu commented Nov 16, 2024

Hi, thank you for your issue!

Currently, we consider headless patching to be almost impossible without patching chromium or major os hook patching.
Id recommend you to just use headful, or emulating displays for example with Xvfb on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants