Chrome proccess stopped before startup complete using chrome-php

439 Views Asked by At

I'm using chrome-php to automate some feature.

My server is Ubuntu 20.04

This is my code:

<?php

require __DIR__ . "/vendor/autoload.php";

use HeadlessChromium\BrowserFactory;

$browserFactory = new BrowserFactory();

// starts headless chrome
$browser = $browserFactory->createBrowser([
    'headless' => false,
    'proxyServer' => '127.0.0.1:8080'
]);

dd($browserFactory);

this will throw exception with this result:

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 error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

Fontconfig error: No writable cache directories

[3350:3350:0831/125919.823336:ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY >[3350:3350:0831/125919.823384:ERROR:env.cc(255)] The platform failed to initialize.

Exiting. in /var/www/afsv.ir/vendor/chrome-php/chrome/src/Browser/BrowserProcess.php:410 Stack trace: #0 /var/www/afsv.ir/v in /var/www/afsv.ir/vendor/chrome-php/chrome/src/Browser/BrowserProcess.php on line 410

And if I remove options from createBrowser() method :

$browser = $browserFactory->createBrowser();

I have these errors :

error: Uncaught Wrench\Exception\HandshakeException:

No accept header receieved on handshake response in /var/www/afsv.ir/vendor/chrome-php/wrench/src/Protocol/Protocol.php:469 Stack

trace: #0 /var/www/afsv.ir/vendor/chrome-php/wrench/src/Client.php(243): Wrench\Protocol\Protocol->validateResponseHandshake()

#1 /var/www/afsv.ir/vendor/chrome-php/chrome/src/Communication/Socket/Wrench.php(99): Wrench\Client->connect()

#2 /var/www/afsv.ir/vendor/chrome-php/chrome/src/Communication/Connection.php(186): HeadlessChromium\Communication\Socket\Wrench->connect()

#3 /var/www/afsv.ir/vendor/chrome-php/chrome/src/Browser/BrowserProcess.php(146): HeadlessChromium\Communication\Connection->connect()

#4 /var/www/afsv.ir/vendor/chrome-php/chrome/src/BrowserFactory.php(81): HeadlessChromium\Browser\BrowserProcess->start()

#5 /var/www/afsv.ir/index.php(16): HeadlessChromium\BrowserFactory->createBrowser()

#6 {main} thrown in /var/www/afsv.ir/vendor/chrome-php/wrench/src/Protocol/Protocol.php on line 469

Does anyone know what wrong in my code or configurations?

Thanks in Advance.

0

There are 0 best solutions below