Chromium Puppeteer 在 AWS Beanstalk 上不再工作。

huangapple go评论68阅读模式
英文:

Chromium puppeeter not working anymore on AWS Beanstalk

问题

我们已经配置了Chromium在AWS Beanstalk上打开PDF。直到最近都一切正常。以下是出现的新错误:

> {"statusCode":400,"message":"无法启动浏览器进程!\n/var/app/current/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome: 无法加载共享库: libatk-1.0.so.0: 没有那个文件或目录\n\n\n故障排除:https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md\n","error":"错误的请求"}

我不知道是否与Beanstalk Linux配置有关。

为了让Chrome Puppeteer之前正常工作,我们使用了以下配置:

.ebextensions/chrome_puppeteer.config:

packages:
  yum:
    compat-libtiff3: []

commands:
  chrome:
    command: curl -k https://intoli.com/install-google-chrome.sh | bash

在 .npmrc 中:
unsafe-perm=true

你能帮我找到另一种解决方案吗?

谢谢

我尝试使用yum命令安装软件包:libatk-1.0.so.0
但没有成功:

> 2023-06-08 11:16:16,116 P7952 [INFO] Command install 2023-06-08
> 11:16:18,226 P7952 [INFO] -----------------------命令输出----------------------- 2023-06-08 11:16:18,226 P7952 [INFO]
> 已加载插件:extras_suggestions、langpacks、priorities、update-motd 2023-06-08 11:16:18,226 P7952 [INFO]
> 没有可用的软件包libatk1.0-0。 2023-06-08 11:16:18,226 P7952 [INFO]
> 错误:无事可做 2023-06-08 11:16:18,226 P7952 [INFO]
> ------------------------------------------------------------ 2023-06-08 11:16:18,227 P7952 [ERROR] 以错误代码1退出

英文:

We have configured Chromium to open PDF on AWS beanstalk. It was working perfectly fine until recently. Here is the new error that appears:

> {"statusCode":400,"message":"Failed to launch the browser process!\n/var/app/current/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory\n\n\nTROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md\n","error":"Bad Request"}

I dont know if it is related to the Beanstalk Linux configuration.

In order to have chrome pupeteer work previously, we used this configuration :

.ebextensions/chrome_pupeteer.config:

packages:
  yum:
    compat-libtiff3: []

commands:
  chrome:
    command: curl -k https://intoli.com/install-google-chrome.sh | bash

and in .npmrc :
unsafe-perm=true

Can you please help me find another solution ?

Thank you

I tried to install with yum command the package: libatk-1.0.so.0
It did not work:

> 2023-06-08 11:16:16,116 P7952 [INFO] Command install 2023-06-08
> 11:16:18,226 P7952 [INFO] -----------------------Command
> Output----------------------- 2023-06-08 11:16:18,226 P7952 [INFO]
> Loaded plugins: extras_suggestions, langpacks, priorities,
> update-motd 2023-06-08 11:16:18,226 P7952 [INFO] No package
> libatk1.0-0 available. 2023-06-08 11:16:18,226 P7952 [INFO] Error:
> Nothing to do 2023-06-08 11:16:18,226 P7952 [INFO]
> ------------------------------------------------------------ 2023-06-08 11:16:18,227 P7952 [ERROR] Exited with error code 1

答案1

得分: 4

我遇到了同样的问题,但是在.NET Core 6.0中使用PuppeteerSharp。我使用了与您相同的intoli install-google-chrome脚本在.ebextensions中。以下是我如何解决的。将您的chrome_puppeteer.config更改为:

commands:
  chrome:
    command: sudo amazon-linux-extras install epel -y && sudo yum install -y chromium

然后,如果您在代码中将PUPPETEER_EXECUTABLE_PATH设置为环境变量,请将其更改为:

/usr/bin/chromium-browser

最后,如果您使用Puppeteer的BrowserFetcherDownloadAsync方法,那么您不必这样做。

似乎intoli安装的Chrome版本缺少新的依赖项(或更多)。经过一些研究,我发现安装AWS EPEL(企业版Linux的额外软件包)然后安装Chromium可以确保所有依赖项存在并与AWS实例良好配合。上述方法也适用于EC2实例。

英文:

I had the same issue, but using PuppeteerSharp with .net core 6.0. I was using the same intoli install-google-chrome script in .ebextensions that you are. Here is how I fixed it. Change your chrome_puppeteer.config to

commands:
  chrome:
    command: sudo amazon-linux-extras install epel -y && sudo yum install -y chromium

Then, if you are setting the PUPPETEER_EXECUTABLE_PATH as an environment variable in your code, change it to:

/usr/bin/chromium-browser

Lastly, if you are using the Puppeteer BrowserFetcher's DownloadAsync method, you don't have to.

It seemed like the intoli installed version of Chrome was missing a new dependency (or more). After some research I found that installing AWS EPEL (Extra Packages for Enterprise Linux) and then Chromium ensured all the dependencies existed and behaved well with AWS instances. The above should work for EC2 instances as well.

huangapple
  • 本文由 发表于 2023年6月9日 13:22:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76437420.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定