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

Fatal Error when using headless=false #142

Closed
Entretoize opened this issue Mar 29, 2020 · 6 comments
Closed

Fatal Error when using headless=false #142

Entretoize opened this issue Mar 29, 2020 · 6 comments

Comments

@Entretoize
Copy link

I'm using chrome in headless mode and it works, but as I have issue that I don't understand I tried to run with the option headless=false and I receive that error :

Fatal error: Uncaught RuntimeException: Chrome process stopped before startup completed. Additional info: mkdir: cannot create directory '/.local': Permission denied touch: cannot touch '/.local/share/applications/mimeapps.list': No such file or directory Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank" (google-chrome:9638): Gtk-WARNING **: cannot open display: in /home/vendor/chrome-php/chrome/src/Browser/BrowserProcess.php on line 386

This is my code :

$browser = $browserFactory->createBrowser(array('headless' => false,         // disable headless mode
    'connectionDelay' => 0.8,   // add 0.8 second of delay between each instruction
    'userAgent' => 'Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) 
    AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',   // mobil uagent
    'debugLogger'     => 'php://stdout')); // will enable verbose mode ));

I don't know what to do.

@alex-rsk
Copy link

alex-rsk commented Mar 30, 2020

I guess you're attempting to run headless chrome in VDS.
Assure, that you installed all dependendcies, like X11.
The first error is related with HOME environment variable. Chrome tries to write his stuff to home dir, which isn't specified, so it tries to write it to non-writable /var/www/.
Try to specify HOME environment variable with SetEnv directive in apache or with fast-cgiparam directive in nginx.conf.

@Entretoize
Copy link
Author

Entretoize commented Mar 30, 2020

Thanks you it removed the error, but i have the following now :
Fatal error: Uncaught RuntimeException: Chrome process stopped before startup completed. Additional info: [25956:25956:0330/064345.882003:ERROR:browser_main_loop.cc(1512)] Unable to open X display. in /var/www/vendor/chrome-php/chrome/src/Browser/BrowserProcess.php on line 379

I have xorg and gnome installed and I can access the graphical interface through proxmox console, doesn't mean x11 is supposed to be installed ?

When I do:
apt-get install xserver-xorg xinit xterm x11-xserver-utils

Everything is already installed.

@alex-rsk
Copy link

Debian (e.g. Ubuntu) Dependencies:

gconf-service
libasound2
libatk1.0-0
libatk-bridge2.0-0
libc6
libcairo2
libcups2
libdbus-1-3
libexpat1
libfontconfig1
libgcc1
libgconf-2-4
libgdk-pixbuf2.0-0
libglib2.0-0
libgtk-3-0
libnspr4
libpango-1.0-0
libpangocairo-1.0-0
libstdc++6
libx11-6
libx11-xcb1
libxcb1
libxcomposite1
libxcursor1
libxdamage1
libxext6
libxfixes3
libxi6
libxrandr2
libxrender1
libxss1
libxtst6
ca-certificates
fonts-liberation
libappindicator1
libnss3
lsb-release
xdg-utils
wget

@Entretoize
Copy link
Author

Entretoize commented Apr 7, 2020

I configured X11, my server is now accessible thought vnc but I still receive the same error
(I'm using $browserFactory = new BrowserFactory("google-chrome");)

@alex-rsk
Copy link

It seems, that the only option for you is to use xvfb (virtual video buffer)
You can try with Xvfb. it does not require additional hardwares.

  1. sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable imagemagick x11-apps
  2. Make sure that Xvfb starts everytime the box/vm is booted:
    Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99
    And try to run google chrome.
    I hope it helps.

@Entretoize
Copy link
Author

Ok, must I remove actual vnc server or anything ? I did that and retried but nothing changed, have I to reboot ?

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

No branches or pull requests

3 participants