Open ltanase77 opened 1 year ago
The error appears when WebDriver needs to start the GeckoDriver with this line of code: $driver = Firefox\FirefoxDriver::start($desiredCapabilities);
If I start manually firefox and gecko driver and I am using $driver = RemoteWebDriver::create($serverUrl, $desiredCapabilities);
everything is fine. But this implies that firefox and geckodriver to run permanently.
My full PHP code below:
$desiredCapabilities = DesiredCapabilities::firefox();
$desiredCapabilities->setCapability('acceptSslCerts', false);
$firefoxOptions = new FirefoxOptions();
$firefoxOptions->addArguments(['-headless', '-vv', '-marionette-port', '0']);
$firefoxOptions->setOption("binary", "/usr/bin/firefox");
$desiredCapabilities->setCapability(FirefoxOptions::CAPABILITY, $firefoxOptions);
$serverUrl = 'http://localhost:4444';
$driver = Firefox\FirefoxDriver::start($desiredCapabilities);
Could you please attach a trace-level log from geckodriver? Read more about reporting actionable bugs in our contribution guidelines.
Where does geckodriver save his log files? How can I locate them? I saw requirements for providing such trace-level log, but I do not know where to find them or how can I obtain them.
This depends on the Selenium binding. As you are using the PHP one as I can see you may want to check their support pages. We actually don't have that in our listing because it's not part of the official Selenium repository.
Alternatively you could try to use geckodriver directly by using eg curl
:
https://firefox-source-docs.mozilla.org/testing/geckodriver/Usage.html#standalone
Does not have geckodriver a default settings which tell where to place the log files? I tried using it directly with curl but I am not able to pass in the curl data the headless flag.
You have to specify it similarly to what is described in our documentation.
But I also have just seen that you are using '-marionette-port', '0'
in the capabilities. This is not needed and might confuse geckodriver. It's doing that actually already on its own. Probably this might already fix it.
I have tried: $firefoxOptions->setOption("log", ["level" => "trace"]);
The exception is the following:
Facebook\WebDriver\Exception\WebDriverCurlException Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"firefox","moz:firefoxOptions":{"binary":"/usr/lib/firefox/firefox","log":{"level":"trace"},"args":["-headless"],"prefs":{"reader.parse-on-load.enabled":false,"devtools.jsonview.enabled":false}},"acceptInsecureCerts":false}]}}
Operation timed out after 180001 milliseconds with 0 bytes received
In the curl request seems that log level is set, but there is no sign of a log file. Or at least I do not know where to look.
geckodriver isn't writing the log to the log file but to stdout
. So probably you ignore the output? Maybe start geckodriver manually in a terminal and running the curl command in a different one.
Ok. I raised an issue with php-webdriver team for not being able to output log files. They set a dev-feature/driver-service-logging branch. I used it and set the log level to trace. This is the output of the geckodriver.log file:
1676027182808 geckodriver INFO Listening on 127.0.0.1:9515
1676027182828 mozrunner::runner INFO Running command: "/usr/lib/firefox/firefox" "--marionette" "-headless" "-no-remote" "-profile" "/tmp/rust_mozprofileLrnVv3"
1676027182828 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1
1676027182828 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027182828 geckodriver::marionette TRACE Retrying in 100ms
[GFX1-]: glxtest: Unable to open a connection to the X server
1676027182928 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027182928 geckodriver::marionette TRACE Retrying in 100ms
1676027183028 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183028 geckodriver::marionette TRACE Retrying in 100ms
[GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt
1676027183129 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183129 geckodriver::marionette TRACE Retrying in 100ms
1676027183229 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183229 geckodriver::marionette TRACE Retrying in 100ms
1676027183329 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183329 geckodriver::marionette TRACE Retrying in 100ms
1676027183429 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183429 geckodriver::marionette TRACE Retrying in 100ms
1676027183529 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183529 geckodriver::marionette TRACE Retrying in 100ms
1676027183630 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183630 geckodriver::marionette TRACE Retrying in 100ms
1676027183730 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183730 geckodriver::marionette TRACE Retrying in 100ms
1676027183830 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183830 geckodriver::marionette TRACE Retrying in 100ms
1676027183930 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027183930 geckodriver::marionette TRACE Retrying in 100ms
1676027184030 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184030 geckodriver::marionette TRACE Retrying in 100ms
1676027184130 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184130 geckodriver::marionette TRACE Retrying in 100ms
1676027184231 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184231 geckodriver::marionette TRACE Retrying in 100ms
1676027184331 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184331 geckodriver::marionette TRACE Retrying in 100ms
1676027184431 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184431 geckodriver::marionette TRACE Retrying in 100ms
1676027184531 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184531 geckodriver::marionette TRACE Retrying in 100ms
1676027184631 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184631 geckodriver::marionette TRACE Retrying in 100ms
1676027184732 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184732 geckodriver::marionette TRACE Retrying in 100ms
1676027184832 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184832 geckodriver::marionette TRACE Retrying in 100ms
1676027184932 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027184932 geckodriver::marionette TRACE Retrying in 100ms
1676027185032 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027185032 geckodriver::marionette TRACE Retrying in 100ms
1676027185132 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027185132 geckodriver::marionette TRACE Retrying in 100ms
1676027185232 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027185232 geckodriver::marionette TRACE Retrying in 100ms
1676027185333 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileLrnVv3/MarionetteActivePort
1676027185333 geckodriver::marionette TRACE Retrying in 100ms
*** You are running in headless mode.
(firefox:6759): dconf-CRITICAL **: 11:44:01.685: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.685: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.686: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.686: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.687: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.849: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.850: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.850: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:44:01.850: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:45:01.687: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:45:01.687: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:45:01.690: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:45:01.690: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:45:01.690: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6759): dconf-CRITICAL **: 11:45:01.690: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
1676029561715 geckodriver::browser TRACE Failed to open /tmp/rust_mozprofileFbK2B6/MarionetteActivePort
The stack trace error for this is:
Facebook\WebDriver\Exception\Internal\WebDriverCurlException Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"firefox","moz:firefoxOptions":{"binary":"/usr/lib/firefox/firefox","log":{"level":"trace"},"args":["-headless"],"prefs":{"reader.parse-on-load.enabled":false,"devtools.jsonview.enabled":false}},"acceptInsecureCerts":false}]}}
Operation timed out after 180001 milliseconds with 0 bytes received
There is no MarionetteActivePort file in the moz profile directory. Just an user.js file. Furthemore there is no .cache directory in the /usr/sbin directory. At least I do not see it.
If i do not set the log level, geckodriver.log file looks like this:
1676028690758 geckodriver INFO Listening on 127.0.0.1:9515
1676028690778 mozrunner::runner INFO Running command: "/usr/lib/firefox/firefox" "--marionette" "-headless" "-no-remote" "-profile" "/tmp/rust_mozprofilesy2VqH"
[GFX1-]: glxtest: Unable to open a connection to the X server
[GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt
*** You are running in headless mode.
(firefox:6417): dconf-CRITICAL **: 11:32:30.820: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.820: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.821: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.821: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.822: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.831: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.831: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.831: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:32:30.831: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:33:30.822: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:33:30.822: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:33:30.825: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:33:30.825: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:33:30.826: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6417): dconf-CRITICAL **: 11:33:30.826: unable to create directory '/usr/sbin/.cache/dconf': Permission denied. dconf will not work properly.
The stack trace error is : Facebook\WebDriver\Exception\TimeoutException Failed to read marionette port
So Firefox doesn't correctly startup on this machine and geckodriver tries only 60s to find the marionette port file. Could you please check if headful mode works? Maybe headless mode needs some library which isn't available. To further investigate this issue probably a Firefox bug should be filed on Bugzilla.
Is there any explanation why the problem did not persist if geckodriver is running in the background, permanently and pops only when php-webdriver try to start geckodriver?
I created a .cache directory in the /usr/sbin and grant it relevant permissions and now (firefox:6417): dconf-CRITICAL error has disappeared from the geckodriver.log file. However the issue is not fixed. So I think the problem is connected with the other error mentioning that geckodriver fails to open /tmp/rust_mozprofile3pRsPd/MarionetteActivePort
. Is just retrying until is timing out.
The issue seems related with this bug Read Marionette port from MarionetteActivePort file within the Firefox profile directory which was closed one year ago.
Running in headful mode results in this error: Error: no DISPLAY environment variable specified.
Manually I can export this DISPLAY variable and firefox starts in headful mode, as I am using Xfvb emulator. But I do not know how to do it when using php-webdriver to start geckodriver.
But I do not know how to do it when using php-webdriver to start geckodriver.
Hi, php-webdriver maintainer here. Environment variables passed to geckodriver
process are (by default) inherited from the parent process (via $_ENV
). So you should be able to pass them like this:
php -i | grep 'variables_order'
and if you don't see "E" in the value (like in "EGPCS") but only something like "GPCS", go to your php.ini and change it to variables_order = "EGPCS"
.php your-script.php
export DISPLAY=...; php your-script.php
Also to add some context, all what php-webdriver does when starting geckodriver binary is just executing command geckodriver -p 9515
, nothing else. However, the environment may actually differ from what you get when running the same command manually (what @ltanase77 says its working fine), because PHP may not by exposing any environment variables to the process (however - I just tried this and it works for me in any scenario, I'm unable to reproduce this locally no Arch linux and it also works fine in GH Actions tests).
I changed my php.ini file as suggested by there is no change. I cannot simply php myscript.php
because the php code sits in Laravel controller and when I am trying php LaravelController.php I get an error like this:
PHP Fatal error: Uncaught Error: Class 'App\Http\Controllers\Controller' not found in
path to my controller. Probably I need to make a custom artisan command to run the controller from the terminal.
I have found that after each failed attempt there is a firefox process still running. It seems that geckodriver start the firefox : /usr/lib/firefox/firefox --marionette -headless -no-remote -profile /tmp/rust_mozprofileetc
. Then it tries to reach a certain file in this rust_mozprofile directories, repsectively: MarionetteActivePort. I do not know if geckodriver is creating such directories or firefox, but somehow it seems geckodriver expect firefox to write a certain file in this directories which firefox does not, for some unknown reasons.
Yes, geckodriver waits for such a file that is created by Marionette after Firefox has started up. If the file doesn't appear then there is a problem with the startup. As said please file a bug for Firefox and tell us the bug number here. I'm happy to continue helping once I'm back and in case no-one did on the bug until then. Thanks.
New Firefox bug created: https://bugzilla.mozilla.org/show_bug.cgi?id=1816409
Same issue here. Unfortunately when i run the docker container with user permissions (in docker compose: user: "${UID:-1000}:${GID:-1000}") i got the same error. When deleted this flag, it works :)
@murkl this is a very interesting information! When you have this flag set, can you start Firefox manually in headless mode? You could try to use the --screenshot
argument which uses headless by default and will exit Firefox once the screenshot has been created.
Changing the permissions didn't help for another user. So it might not be the right solution.
Anyone who can see this could you please run the test with the environment variable MOZ_LOG="Process:5"
set? I would like to know if there might be something interesting in the trace log of geckodriver.
@ltanase77 or @murkl would you mind trying out what I suggested in my last comment? I would appreciate any feedback so that we can get it investigated. Thanks!
This is an log output if a set environment variable MOZ_LOG="Process:5" *** You are running in headless mode. [GFX1-]: glxtest: Unable to open a connection to the X server [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess for type privilegedabout [Parent 18878: Main Thread]: D/Process Launching new process immediately for type privilegedabout [Parent 18878: Main Thread]: V/Process CreateSubprocess: ContentParent 7faaa2c07f00 mSubprocess 7faaa3250c80 handle 0 [Parent 18878: Main Thread]: D/Process AddBlocker: privilegedabout 7faaa2c07f00 (sNumBlockers=0) [Parent 18878: Main Thread]: D/Process Enabling preallocation: 3 [Parent 18878: Main Thread]: D/Process Starting delayed process start, delay=1000 [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess: new immediate process 7faaa2c07f00 [Parent 18878: Main Thread]: D/Process ContentParent::InitInternal: 7faaa2c07f00 [Child 18921: Main Thread]: D/Process Changed name of process 18921 to Web Content [Child 18921: Main Thread]: D/Process Setting remoteType of process 18921 to privilegedabout [Child 18921: Main Thread]: D/Process Changed name of process 18921 to Privileged Content [Parent 18878: Main Thread]: V/Process RecvFirstIdle 7faaa2c07f00: Removing Blocker for privilegedabout [Parent 18878: Main Thread]: D/Process RemoveBlocker: privilegedabout 7faaa2c07f00 (sNumBlockers=1) [Parent 18878: Main Thread]: D/Process Blocked preallocation for 162.704997ms [Parent 18878: Main Thread]: D/Process Starting delayed process start, delay=1000 [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess for type extension [Parent 18878: Main Thread]: D/Process Launching new process immediately for type extension [Parent 18878: Main Thread]: V/Process CreateSubprocess: ContentParent 7faa9a646100 mSubprocess 7faa9a882740 handle 0 [Parent 18878: Main Thread]: D/Process AddBlocker: extension 7faa9a646100 (sNumBlockers=0) [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess: new immediate process 7faa9a646100 [Parent 18878: Main Thread]: D/Process ContentParent::InitInternal: 7faa9a646100 [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess for type extension [Parent 18878: Main Thread]: D/Process GetUsedProcess: Reused process 7faa9a646100 (2) for extension [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess for type extension [Parent 18878: Main Thread]: D/Process GetUsedProcess: Reused process 7faa9a646100 (2) for extension [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess for type extension [Parent 18878: Main Thread]: D/Process GetUsedProcess: Reused process 7faa9a646100 (2) for extension [Parent 18878: Main Thread]: D/Process GetNewOrUsedProcess for type extension [Parent 18878: Main Thread]: D/Process GetUsedProcess: Reused process 7faa9a646100 (2) for extension [Child 18969: Main Thread]: D/Process Changed name of process 18969 to Web Content [Child 18969: Main Thread]: D/Process Setting remoteType of process 18969 to extension [Child 18969: Main Thread]: D/Process Changed name of process 18969 to WebExtensions [Parent 18878: Main Thread]: D/Process Starting process allocate on idle [Parent 18878: Main Thread]: D/Process Starting process allocate on idle [Parent 18878: Main Thread]: D/Process Trying to start process now [Parent 18878: Main Thread]: D/Process Starting delayed process start, delay=1000 [Parent 18878: Main Thread]: D/Process Trying to start process now [Parent 18878: Main Thread]: D/Process Starting delayed process start, delay=1000 [Parent 18878: Main Thread]: V/Process RecvFirstIdle 7faa9a646100: Removing Blocker for extension [Parent 18878: Main Thread]: D/Process RemoveBlocker: extension 7faa9a646100 (sNumBlockers=1) [Parent 18878: Main Thread]: D/Process Blocked preallocation for 838.870148ms [Parent 18878: Main Thread]: D/Process Starting delayed process start, delay=1000 [Parent 18878: Main Thread]: D/Process Starting process allocate on idle [Parent 18878: Main Thread]: D/Process Trying to start process now [Parent 18878: Main Thread]: V/Process CreateSubprocess: ContentParent 7faa97764100 mSubprocess 7faa99f9cac0 handle 0 [Parent 18878: Main Thread]: D/Process Preallocated = 1 of 3 processes [Parent 18878: Main Thread]: D/Process Starting process allocate on idle [Parent 18878: Main Thread]: D/Process Trying to start process now [Parent 18878: Main Thread]: V/Process CreateSubprocess: ContentParent 7faa97762d00 mSubprocess 7faa96ab1740 handle 0 [Parent 18878: Main Thread]: D/Process Preallocated = 2 of 3 processes [Parent 18878: Main Thread]: D/Process ContentParent::InitInternal: 7faa97764100 [Parent 18878: Main Thread]: D/Process Starting process allocate on idle [Parent 18878: Main Thread]: D/Process Trying to start process now [Parent 18878: Main Thread]: V/Process CreateSubprocess: ContentParent 7faa97760a00 mSubprocess 7faa96ab1200 handle 0 [Parent 18878: Main Thread]: D/Process Preallocated = 3 of 3 processes [Parent 18878: Main Thread]: D/Process ContentParent::InitInternal: 7faa97762d00 [Parent 18878: Main Thread]: D/Process ContentParent::InitInternal: 7faa97760a00 [Child 19007: Main Thread]: D/Process Changed name of process 19007 to Web Content [Child 19006: Main Thread]: D/Process Changed name of process 19006 to Web Content [Child 19009: Main Thread]: D/Process Changed name of process 19009 to Web Content [Child 19006: Main Thread]: D/Process Setting remoteType of process 19006 to prealloc [Child 19006: Main Thread]: D/Process Changed name of process 19006 to Web Content [Child 19007: Main Thread]: D/Process Setting remoteType of process 19007 to prealloc [Child 19009: Main Thread]: D/Process Setting remoteType of process 19009 to prealloc [Child 19009: Main Thread]: D/Process Changed name of process 19009 to Web Content [Child 19007: Main Thread]: D/Process Changed name of process 19007 to Web Content [Parent 18878: Main Thread]: D/Process Starting process allocate on idle [Parent 18878: Main Thread]: D/Process Trying to start process now [GFX1-]: Unrecognized feature ACCELERATED_CANVAS2D
Thanks a lot! I copied this info over to the Bugzilla bug and will continue over there. Lets see if the found details might be helpful.
I'm having the same issue, any update about how to fix it?
Distributor ID: Debian Description: Debian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye
[critical] Uncaught PHP Exception Facebook\WebDriver\Exception\TimeoutException: "Failed to read marionette port" at /vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php line 136
It appears to be failing only on Debian, as I have tested it on Ubuntu 22.04.2 LTS and it works fine.
did anyone solved this issue? myself same problem. Ok if I run geckodriver manually, no way to make it work from phpwebdriver. I'm using Debian 11
did anyone solved this issue? myself same problem. Ok if I run geckodriver manually, no way to make it work from phpwebdriver. I'm using Debian 11
Interesting. Could you provide trace logs from geckodriver for both cases? I would like to see the difference in how the browser gets started. It sounds like an issue with phpwebdriver then.
@whimboo here below the log of the manual run from bash. NO idea on how to do the log on automatic run :-(
In php I have
$usr_dir = "/tmp/firefox/profile/"; $host = 'http://localhost:4444'; putenv('WEBDRIVER_FIREFOX_DRIVER=/usr/local/bin/geckodriver'); $firefoxOptions = new FirefoxOptions(); $firefoxOptions->addArguments(['-headless']); $firefoxOptions->addArguments(["-profile", "$usr_dir"]); $firefoxOptions->setOption("binary", '/opt/firefox/./firefox'); $firefoxOptions->setOption("log", ["level" => "trace"]); // Create $capabilities and add configuration from ChromeOptions $capabilities = DesiredCapabilities::firefox(); $capabilities->setCapability(FirefoxOptions::CAPABILITY, $firefoxOptions ); $capabilities->setPlatform(WebDriverPlatform::LINUX);
$driver = RemoteWebDriver::create($host, $capabilities); $driver->get('https://www.google.it'); $driver->close();
@whimboo here is instead the log when I start from PHP. The issue is always the same Failed to open /tmp/firefox/profile/MarionetteActivePort
@ssada1975 when you run the script via PHP do you have another Firefox instance open at the same time on the same machine? If yes, can you please close it and check if that makes a difference? When you start it manually is there another Firefox instance as well or not?
After restarting completely the server, same issue with auto start Also killing all firefox instances, same issue with auto start.
Oh, @ssada1975 when running geckodriver via PHP I assume the user is different as when you run it yourself. Would you mind checking if manually starting geckodriver by using that other user (something like www-data
) produces the same error? Maybe some permissions aren't set or are explicitly set to prevent launching specific apps.
@whimboo how can I run geckodriver as another user?
@whimboo confirm that if i run manually geckodriver as www-data, "su -pc geckodriver www-data", it doesn't work likewise if I run automatically
root@714e8dfc4dd1:~# su -pc geckodriver www-data bash: /root/.bashrc: Permission denied 1688589263837 geckodriver INFO Listening on 127.0.0.1:4444 1688589266837 geckodriver::browser DEBUG Backing up prefs to "/tmp/firefox/profile/user.geckodriver_backup_1" 1688589266846 mozrunner::runner INFO Running command: MOZ_CRASHREPORTER="1" MOZ_CRASHREPORTER_NO_REPORT="1" MOZ_CRASHREPORTER_SHUTDOWN="1" MOZ_NO_REMOTE="1" "/opt/firefox/./firefox" "--marionette" "-headless" "-vv" "-profile" "/tmp/firefox/profile/" "--shm-size 2g" "-no-remote" 1688589266848 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1 1688589266849 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589266849 geckodriver::marionette TRACE Retrying in 100ms *** You are running in headless mode. 1688589266951 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589266952 geckodriver::marionette TRACE Retrying in 100ms [GFX1-]: glxtest: Unable to open a connection to the X server 1688589267052 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267055 geckodriver::marionette TRACE Retrying in 100ms 1688589267156 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267159 geckodriver::marionette TRACE Retrying in 100ms [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt 1688589267259 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267260 geckodriver::marionette TRACE Retrying in 100ms 1688589267360 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267360 geckodriver::marionette TRACE Retrying in 100ms 1688589267460 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267460 geckodriver::marionette TRACE Retrying in 100ms 1688589267561 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267561 geckodriver::marionette TRACE Retrying in 100ms 1688589267661 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267661 geckodriver::marionette TRACE Retrying in 100ms 1688589267761 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267761 geckodriver::marionette TRACE Retrying in 100ms 1688589267861 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267862 geckodriver::marionette TRACE Retrying in 100ms 1688589267962 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589267962 geckodriver::marionette TRACE Retrying in 100ms 1688589268062 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268062 geckodriver::marionette TRACE Retrying in 100ms 1688589268163 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268163 geckodriver::marionette TRACE Retrying in 100ms 1688589268263 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268263 geckodriver::marionette TRACE Retrying in 100ms 1688589268363 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268363 geckodriver::marionette TRACE Retrying in 100ms 1688589268464 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268464 geckodriver::marionette TRACE Retrying in 100ms 1688589268564 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268564 geckodriver::marionette TRACE Retrying in 100ms 1688589268664 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268664 geckodriver::marionette TRACE Retrying in 100ms 1688589268764 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268764 geckodriver::marionette TRACE Retrying in 100ms 1688589268865 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268865 geckodriver::marionette TRACE Retrying in 100ms 1688589268965 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589268965 geckodriver::marionette TRACE Retrying in 100ms 1688589269065 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269065 geckodriver::marionette TRACE Retrying in 100ms 1688589269165 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269165 geckodriver::marionette TRACE Retrying in 100ms 1688589269266 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269266 geckodriver::marionette TRACE Retrying in 100ms 1688589269366 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269366 geckodriver::marionette TRACE Retrying in 100ms 1688589269466 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269466 geckodriver::marionette TRACE Retrying in 100ms 1688589269566 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269566 geckodriver::marionette TRACE Retrying in 100ms 1688589269667 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269667 geckodriver::marionette TRACE Retrying in 100ms 1688589269767 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269767 geckodriver::marionette TRACE Retrying in 100ms 1688589269867 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269867 geckodriver::marionette TRACE Retrying in 100ms 1688589269967 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589269967 geckodriver::marionette TRACE Retrying in 100ms 1688589270068 geckodriver::browser TRACE Failed to open /tmp/firefox/profile/MarionetteActivePort 1688589270068 geckodriver::marionette TRACE Retrying in 100ms
(firefox:6288): dconf-CRITICAL **: 20:34:30.157: unable to create directory '/root/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6288): dconf-CRITICAL **: 20:34:30.157: unable to create directory '/root/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6288): dconf-CRITICAL **: 20:34:30.162: unable to create directory '/root/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6288): dconf-CRITICAL **: 20:34:30.163: unable to create directory '/root/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6288): dconf-CRITICAL **: 20:34:30.163: unable to create directory '/root/.cache/dconf': Permission denied. dconf will not work properly.
(firefox:6288): dconf-CRITICAL **: 20:34:30.163: unable to create directory '/root/.cache/dconf': Permission denied. dconf will not work properly.
@ssada1975 thanks a lot! So could you now try to start Firefox by using the www-data
user? I would assume that it doesn't start as well. If that is the case it would be best to get a bug filed for Firefox directly. Let me know and I can guide you.
Oh, I actually found https://answers.launchpad.net/ubuntu/+question/695824. As it looks like www-data
doesn't have a home directory by default and as such Firefox fails to store the profile. Comment 5 on this bug tracker issue should help you. Please let us know.
Hi whimboo! So, in the home directory should I create a www-data folder with the same write access as the other user, where firefox will create the .mozilla folder when run by www-data user?
@ltanase77 please have a look at https://linuxhandbook.com/create-home-directory-existing-user/. That should do it.
sudo mkhomedir_helper www-data
does not create a home directory for www-data user.
The home directory for www-data user seems to be /var/www where a .profile, .bashrc and bash_logout file exists
no way to make it works, even creating /var/www/.cache or .mozilla and giving rights to www-data
In my case the www-data is set as nologin user and probably that's why I cannot create a home directory.
@ltanase77 in the world we are just you and me not being able to run geckodriver automatically from Php? 😭 It sounds crazy there is no solution
I have somehow bypass the problem, by running geckodriver as background process with nohup geckodriver
and then instead of $driver = Firefox\FirefoxDriver::start($desiredCapabilities);
I am using $driver = RemoteWebDriver::create($serverUrl, $desiredCapabilities);
In this way I was able to schedule a Laravel job that is running automatically daily at certain hours, using the php-webdriver for scraping info from a certain website.
@ltanase77 thanks for checking. So there is indeed a problem in starting Firefox with the www-data
user, and some missing permissions. Could you maybe check if that really only applies to headless? I assume that headful will also be affected the same way.
Do you actually see where geckodriver tries to create the temporary Firefox profile? Is it also under /tmp/firefox/...
? I assume www-data
doesn't have access to? Also you could start geckodriver with the --profile-root
argument (which is new since version 0.32.0) and specify the /var/www/
folder. Does that work then?
I am using aws lightsail bitnami lamp stack, which according with their docs runs apache and php under daemon user and group. Starting geckodriver manually with --profile-root /var/www-data
returns this errorgeckodriver: error: Unable to write to temporary directory; consider --profile-root with a writeable directory
Geckodriver is creating temporary firefox profile in directly in /tmp by creating a folder rust_mozprofile{uid}. Some of such folders are created by the daemon user, some by the ssh user under which I log in the machine. I assume that when php-webdriver is trying to start geckodriver is using the daemon user under which php is running.
System
Testcase
Stacktrace
Facebook\WebDriver\Exception\TimeoutException Failed to read marionette port (Most recent call first) at (unknown method)(/opt/bitnami/sites/Cabinet/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:133) at Facebook\WebDriver\Exception\WebDriverException::throwException(/opt/bitnami/sites/Cabinet/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:385) at Facebook\WebDriver\Remote\HttpCommandExecutor::execute(/opt/bitnami/sites/Cabinet/vendor/php-webdriver/webdriver/lib/Remote/Service/DriverCommandExecutor.php:42) at Facebook\WebDriver\Remote\Service\DriverCommandExecutor::execute(/opt/bitnami/sites/Cabinet/vendor/php-webdriver/webdriver/lib/Firefox/FirefoxDriver.php:61) at Facebook\WebDriver\Firefox\FirefoxDriver::startUsingDriverService(/opt/bitnami/sites/Cabinet/vendor/php-webdriver/webdriver/lib/Firefox/FirefoxDriver.php:33) at Facebook\WebDriver\Firefox\FirefoxDriver::start(/opt/bitnami/sites/Cabinet/app/Http/Controllers/Maps/CheckLaw.php:60)
Trace-level log