Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

python - What does "Client failed to connect to the D-BUS daemon" mean?

I am using a very complex setup to test various non-public webpages. I use jenkins to run the python-selenium tests within a dockerimage. That way, I am completely independent of the jenkins environment and can create my own environment. In this environment I have the following software installed:

  • Ubuntu 16.04.3
  • Firefox: Mozilla Firefox 57.0.1
  • geckodriver: 0.18.0
  • nosetests: 1.3.7
  • selenium: 3.8.0

When running the tests, which mostly succeed, I see in the geckodriver.log output messages like

(firefox:55): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message

My questions:

  • What does this message mean?
  • Could that be an indication of the reason why sometimes the tests are failing?
  • If so, how to fix it?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The error you are seeing is :

(firefox:55): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message

So it is clear Firefox attempts to connect to D-BUS daemon and fails as dbus-launch gets terminated abnormally.


dbus-launch

dbus-launch is basically the utility to start a message bus by firefox through a shell script. It would normally be called from a user's login scripts. dbus-launch launches a session bus instance and print the address and pid of that instance to standard output.

You can read more about dbus-launch from the Linux man page


Root Cause

This error can arise if you use su (root), sudo, suedit, gksu. The main reason is DBUS_SESSION_BUS_ADDRESS retains its value when you su instead of picking up the value in /root/.dbus/session-bus.

Here you will find a detailed discussion on GConf Error: No D-BUS daemon running?! How to reinstall or fix?.

Another possible reason may be the base Firefox Browser version may be an older version on which updates were taken to reach the current version.


Solution :

There are a couple of solutions available to address this related issue as follows :

  • Before you start Firefox you have to type export $(dbus-launch)
  • However this may result into another error with NSS_USE_SHARED_DB. So you have to use export NSS_USE_SHARED_DB=ENABLED as well.
  • The most convenient way would be to put all the configuration with in .bashrc file :

    export $(dbus-launch)
    export NSS_USE_SHARED_DB=ENABLED
    firefox &
    

This discussion speaks about the solution in details.

  • If dbus-launch is not installed on your system you have to install dbus-x11 package which contains the dbus-launch program.
  • An effective solution would be to uninstall the older base version of Firefox Browser and install a recent released GA version of Firefox Browser.

Best Approach

The issue with dbus-launch was addressed properly by both Ubuntu and Mozila. To overcome this error you need to follow the below mentioned steps :

  • Keep your Ubuntu updated with the Latest Patch Releases and updates.
  • Always use the latest released version of Selenium-Python client, WebDriver variant e.g. GeckoDriver and Web Browser, e.g. Firefox Browser.
  • Clean and Build the Project Workspace afresh through your IDE before and after executing your Test Suite.
  • Clear the Browser Cache before and after the execution of your Tests.
  • If you have to uninstall any of the Web Client variants (e.g. Mozilla Firefox) you can use Revo Uninstallar with Moderate Memory Scan so that the stale registry settings are discarded.
  • Use CCleaner tool regularly to wipe away the OS chores including the stale rust_mozprofile directories.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...