-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Firefox fails to start-up on Debian 10 in headless mode (Failed to open MarionetteActivePort) #2082
Comments
The error appears when WebDriver needs to start the GeckoDriver with this line of code:
|
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 |
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 |
I have tried: The exception is the following:
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 |
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:
|
The stack trace error for this is:
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:
The stack trace error is : |
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 |
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: |
Hi, php-webdriver maintainer here. Environment variables passed to
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 |
I changed my php.ini file as suggested by there is no change. I cannot simply |
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 |
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 |
@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! |
You can use the |
@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 (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 |
Oh, I actually found https://answers.launchpad.net/ubuntu/+question/695824. As it looks like |
Hi whimboo! |
@ltanase77 please have a look at https://linuxhandbook.com/create-home-directory-existing-user/. That should do it. |
|
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? 😭 |
I have somehow bypass the problem, by running geckodriver as background process with |
@ltanase77 thanks for checking. So there is indeed a problem in starting Firefox with the Do you actually see where geckodriver tries to create the temporary Firefox profile? Is it also under |
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 |
@ltanase77 and @whimboo here are my steps it starts but again same problem not finding marionette port |
Not sure if helps, but if i run a batch with the above sh instruction from PHP and print output i get geckodriver 0.33.0 (a80e5fd61076 2023-04-02 18:31 +0000) WebDriver implementation for Firefox USAGE: geckodriver [OPTIONS] OPTIONS: --allow-hosts ... List of hostnames to allow. By default the value of --host is allowed, and in addition if that's a well known local address, other variations on well known local addresses are allowed. If --allow-hosts is provided only exactly those hosts are allowed. --allow-origins ... List of request origins to allow. These must be formatted as scheme://host:port. By default any request with an origin header is rejected. If --allow-origins is provided then only exactly those origins are allowed. --android-storage Selects storage location to be used for test data (deprecated). [possible values: auto, app, internal, sdcard] -b, --binary Path to the Firefox binary --connect-existing Connect to an existing Firefox instance -h, --help Prints this message --host Host IP to use for WebDriver server [default: 127.0.0.1] --jsdebugger Attach browser toolbox debugger for Firefox --log Set Gecko log level [possible values: fatal, error, warn, info, config, debug, trace] --log-no-truncate Disable truncation of long log lines --marionette-host Host to use to connect to Gecko [default: 127.0.0.1] --marionette-port Port to use to connect to Gecko [default: system-allocated port] -p, --port Port to use for WebDriver server [default: 4444] --profile-root Directory in which to create profiles. Defaults to the system temporary directory. -v Log level verbosity (-v for debug and -vv for trace level) -V, --version Prints version and copying information --websocket-port Port to use to connect to WebDriver BiDi [default: 9222] |
@ssada1975 sorry for the late reply but I was out the last three weeks. This log shows that there was a problem with specifying arguments. Could you try again by using |
@ltanase77 yes, if PHP starts geckodriver it will automatically run under the same user. So if you specify the Also (as already asked the last time) could you try without Thanks. |
@whimboo same problem root@a91c65994790:/home# su -pc "geckodriver --profile-root=/tmp/firefox/profile" www-data |
@ssada1975 but has |
@ltanase77 or @ssada1975 do you have any further feedback to my above question? Thanks a lot! |
@whimboo I created a group that should give rights both to root and www-data but no changes, always same errors as above |
|
@MatzFan how do you run geckodriver? Is it with your normal user account or a different one? Does the Firefox profile in use have the correct permissions so that Firefox can write to it? |
Hi @whimboo, thanks for your response. I'm using Selenium (Ruby bindings). I have not modified the permissions for my profile and in any case I'm starting a Selenium driver without a profile. I'm not using a different user account. It is actually Tor Browser I'm using too, not regular Firefox. My project is a Selenium-driver Tor Browser. I've now managed a workaround for my tests by using Xvfb. This showed up an issue that I needed to set the screen dimensions, as when using the default screen size it was smaller than my specified Selenium window size and WebGL did not work. It works now I have set the screen size large enough. |
Ok, good to hear that a workaround via xvfb works for you. I cannot give a promise when headless will work given that this is outside of our team, and it's still not clear what affects that. Sadly I don't have a way to reproduce at the moment. |
I had a lot of problems troubleshooting a similar issue. The problem was that we run our docker container with user:group of the host (=dev) machine. Headless Firefox does not like that at all. The solution was to run Firefox with sudo. Here is a complete writeup: |
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
The text was updated successfully, but these errors were encountered: