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

Websocket context Timeout #1367

Closed
KThrishul opened this issue Oct 9, 2023 · 4 comments
Closed

Websocket context Timeout #1367

KThrishul opened this issue Oct 9, 2023 · 4 comments

Comments

@KThrishul
Copy link

KThrishul commented Oct 9, 2023

Hi, We are facing the error "websocket url timeout reached" when we reach request limit of 200

Here is the code example:

ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
defer cancel()
secondCtx, cancel := chromedp.NewContext(ctx)

Could you please help me out..

@ZekeLu
Copy link
Member

ZekeLu commented Oct 13, 2023

A browser instance consumes many resources and a system has limited resources. You should try to limit the number of browser instances/tabs. Usually, you can use a channel to do that. See https://go.dev/doc/effective_go#channels.

And usually, it's better to use a single browser instance. See #752 (comment).

@KThrishul
Copy link
Author

Thank you, that did solve my problem.

I do have one more question. How to we limit the system resource while converting html to pdf using PrintToPdf for a single instance.

I can see that resources are used by the following:

  1. Renderer
  2. Utility
  3. Zygote --no-zygote-sandbox
  4. Zygote --no-sandbox
  5. gpu-process

Are all this process are required to convert. If not, can we discard any of it. If yes, how?
Please help with this.

@ZekeLu
Copy link
Member

ZekeLu commented Nov 2, 2023

The behavior of the browser is controlled by the switches. You can find a full list of the switches here: https://peter.sh/experiments/chromium-command-line-switches/.

I don't know which combination of the switches will make it consume less resources. Generally, chromedp/headless-shell consumes less resources. You can give it a try.

@KThrishul
Copy link
Author

Thank you updates
It's was really helpful

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