this is my config on the puppeteer cluster :
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
workerCreationDelay: 2000,
puppeteerOptions:{args: ['--no-sandbox', '--disable-setuid-sandbox']},
maxConcurrency: numCPUs,
});
when I try to run in my host it comes with error:
Error: Failed to launch the browser process!
[1014/132057.583562:ERROR:zygote_host_impl_linux.cc(90)] Running as
root without --no-sandbox is not supported. See
https://crbug.com/638180.
but according to the documentation of puppeter cluster you can pass the puppeteer option in puppeteerOptions
why passing options are not working?
Related
chromium not working on google colab
Hi, I want to run puppeteer on google colab.
running test code with !node --trace-warnings test.js says:
Command '/usr/bin/chromium-browser' requires the chromium snap to be installed. Please install it with:snap install chromium
installed chromium with
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!apt install chromium-browser # also gave same result
puppeteer code
const puppeteer = require('puppeteer');
//varv');
const dotenv = require('dotenv');
dotenv.config();
(async () => {
const browser = await puppeteer.launch({executablePath: '/usr/bin/chromium-browser'});
const page = await browser.newPage();
await page.goto('https://www.google.com');
await page.screenshot({
path: 'google.png',
fullPage: true
});
await browser.close();
})();
Tried
I tried installing chromium with 'snap install chromium' it says:
error: cannot communicate with server: Post http://localhost/v2/snaps/chromium: dial unix /run/snapd.socket: connect: no such file or directory
Tried installing snapd
!systemctl status snapd.service # snapd: unrecognized service
!sudo apt update && upgrade
!sudo apt install snapd
!which snapd # error: cannot communicate with server: Post http://localhost/v2/snaps/chromium: dial unix /run/snapd.socket: connect: no such file or directory
Tried brave-browser
installation code: https://brave.com/linux/
executablePath: "/opt/brave.com/brave"
error: (node:42514) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! spawn /opt/brave.com/brave EACCES
chmod +x /opt/brave.com/brave # did not solve
Tried google-chrome: Worked while creating this question
installation code: https://brave.com/linux/
executablePath: "/opt/google/chrome/chrome"
references:
https://colab.research.google.com/drive/168X6Zo0Yk2fzEJ7WDfY9Q_0UOEmHSrZc?usp=sharing#scrollTo=_Yf4OfPBAAPR
https://forum.snapcraft.io/t/snap-d-error-cannot-communicate-with-server-connection-refused/6093/23
To use Chromium with Puppeteer on Google Colab, you can install Puppeteer and launch Chromium using the following code:
!pip install puppeteer
Now python Code.
import asyncio
from pyppeteer import launch
async def main():
browser = await launch(headless=False, args=['--no-sandbox'])
page = await browser.newPage()
await page.goto('https://www.example.com')
await browser.close()
asyncio.get_event_loop().run_until_complete(main())
Note that the headless option is set to False to launch a visible Chromium browser. The --no-sandbox argument is also added to run Chromium in a containerized environment, which is necessary when running on Google Colab.
With this code, you can launch a Chromium browser, create a new page, navigate to a URL, and close the browser, all using Puppeteer. From here, you can use the Puppeteer API to automate tasks or extract data from web pages.
// executablePath is specified
const browser = await puppeteer.launch({
executablePath: '/path/to/chrome'
});
// // executablePath is not specified
const browser = await puppeteer.launch();
// This will not work.
// console.log('executablePath is', browser.executablePath)
If we do not specify a value for the executablePath option, Puppeteer will try to find the default installation of Chrome or Chromium on the system. On Windows, this is usually C:\Program Files (x86)\Google\Chrome\Application\chrome.exe. On macOS and Linux, Puppeteer will try to use the chrome or chromium executable in the PATH.
How we can find out which executable is getting used by Puppetter in Puppeteer script itself?
https://pptr.dev/api/puppeteer.puppeteernode.executablepath
const puppeteer = require('puppeteer')
console.log(puppeteer.executablePath())
Example output on my node-18 docker image is
root#021100c40ec4:/usr/src/app# node -e "console.log(require('puppeteer').executablePath())"
/root/.cache/puppeteer/chrome/linux-1069273/chrome-linux/chrome
I'm using the plugin gatsby-remark-mermaid which also includes installing puppeteer. The mermaid diagrams are rendered properly on my end, however it gets an error on the build. Here is the error message:
Failed to launch the browser process!
/tmp/build/node_modules/puppeteer/.local-chromium/linux-970485/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
I looked into the documentation and since I'm running it on Heroku, I must include this configuration:
puppeteer.launch({ args: ['--no-sandbox'] });
I tried using it on gatsby-browser.js like this, but I only got errors instead.
const puppeteer = require('puppeteer')
const browser = await puppeteer.launch({ args: ['--no-sandbox'] })
Where do I need to put this configuration for it to work?
I am trying to make the connection between chrome (v - 67) and chrome (v- 79), at the time got the error like:
WebSocket connection to 'wss://global.vss.twilio.com/signaling' failed: Error in connection establishment: net:: ERR_SOCKS_CONNECTION_FAILED
I have attached the video link here. please check out and let me help out for this.
Chrome (v-79) : connection is successfully.
check below url- https://drive.google.com/file/d/1aVsRhDEmp7q1atAwMcbh9L_bPv-iiqNA/view
Chrome(v-67): Could not connect to Twilio: Signaling connection error
check URL: https://drive.google.com/file/d/1TbGaJ_aSyfswTGOXA-8Sw1u_s_skBH-C/view
I have added below option in connectOptions
const connectOptions = {
_useTwilioConnection: true
};
But I have faced the same issue. I have created an Http tunnel. So, If you want to check this feature using my end.
please hit this link: https://b256e195.ngrok.io
Code to reproduce the issue:
Video.connect(data.token, connectOptions).then(roomJoined, function (error) {
alert("Video connect error part");
console.log(error);
log('Could not connect to Twilio: ' + error.message);
});
Expected behavior:
I need to work on both sides.
Actual behavior:
The connection could not establish in chrome (v-67)
Software versions:
[x] Browser(s): Chrome(v-79), Chrome(v-67) (not working), Chrome(v-75) (not working)
[x] Operating System: window 10
[x] twilio-video.js: we have migrate from 1.x to 2.x
[x] Third-party libraries (e.g., Angular, React, etc.): Angular js
I am programatically launching a new instance using the Compute Engine API for Go [1], and a tool I made called vmproxy [2].
The problem I have is that if I launch a preemptible VM using a startup-script-url pointing to https://bitbucket.org/ronoaldo/debian-custom/raw/tip/tools/autobuild, the build script fails to download. I can see in the serial console output that the the startup script metadata is there, and that it attempts to be downloaded with curl, but that part fails.
However, if I reset the instance via the developers console, the script is properly downloaded and runs nicelly.
The code I am using to setup the instance is:
// Ronolinux is a VM Proxy that runs an live systems build on Compute Engine
var (
Ronolinux = &vmproxy.VM{
Path: "/",
Instance: vmproxy.Instance{
Name: "ronolinux-buildd",
Zone: "us-central1-f",
Image: vmproxy.ResourcePrefix + "/debian-cloud/global/images/debian-8-jessie-v20150915",
MachineType: "n1-standard-1",
Metadata: map[string]string{
"startup-script-url": "https://bitbucket.org/ronoaldo/debian-custom/raw/tip/tools/autobuild",
"shutdown-script": `!#/bin/bash
gsutil cp /var/log/startupscript.log gs://ronoaldo/ronolinux/build-$(date +%Y%m%d%H%M%S).log
`,
},
Scopes: []string{ storageReadWrite },
},
}
)
[1] https://godoc.org/google.golang.org/api/compute/v1
[2] https://godoc.org/ronoaldo.gopkg.net/aetools/vmproxy
If your startup script is not hosted on Cloud Storage, there is a random chance the download will fail. If you look at the serial console output, make sure to scroll horizontally, as it will not wrap long lines. In my case, the error line was very long, and this hidded the real end of the message:
(... long curl on-line progress output )
curl: (7) Failed to connect to bitbucket.org port 443: Connection timed out
(...)
Your host must respond within a 10s timeout. In my case, the first boot usually failed to contact Bitbucket, hence failing to download the script; a VM reset also made things work, as the network latency outside Google Cloud were probably better.
I ended up moving to host the script on cloud storage to avoid these issues.