5

Ubuntu Server 16.04 running in VirtualBox

Setup

sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install xvfb dbus-x11 google-chrome-stable

Test

$xvfb-run -a --server-args='-screen 0, 1024x768x16' google-chrome -start-maximized http://example.com > /dev/null &

$ ps auxx | grep Xvfb
user   1355  1.2  1.6 174992 33808 ?        S    13:21   0:30 Xvfb :99 -screen 0, 1024x768x16 -nolisten tcp -auth /tmp/xvfb-run.adDyGd/Xauthority

$ cat /tmp/xvfb-run.adDyGd/Xauthority
user99MIT-MAGIC-COOKIE-1��gj��/�������auser@user:~$

Problem

$ xdpyinfo -display :99
No protocol specified
xdpyinfo:  unable to open display ":99".
  • What does "No protocol specified" mean?
  • What could cause xdpyinfo to fail here?

UPDATE 5/16/2016

Starting Xvfb manually and defining the display number before running chrome, works. However xvfb-run does not.

Xvfb manually

$ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install xvfb dbus-x11 google-chrome-stable

$ Xvfb :99 -screen 0 1024x768x24 > /dev/null &

$ xdpyinfo -display :99
name of display:    :99
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    11803000
X.Org version: 1.18.3
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    6
supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 4, bits_per_pixel 8, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 16, bits_per_pixel 16, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    depth 32, bits_per_pixel 32, scanline_pad 32
keycode range:    minimum 8, maximum 255
focus:  PointerRoot
number of extensions:    25
    ...
default screen number:    0
number of screens:    1

screen #0:
  dimensions:    1024x768 pixels (260x195 millimeters)
  resolution:    100x100 dots per inch
  depths (6):    24, 1, 4, 8, 16, 32
  root window id:    0x25c
  depth of root window:    24 planes
  number of colormaps:    minimum 1, maximum 1
  default colormap:    0x20
  default number of colormap cells:    256
  preallocated pixels:    black 0, white 16777215
  options:    backing-store WHEN MAPPED, save-unders NO
  largest cursor:    1024x768
  current input event mask:    0x0
  number of visuals:    240
  default visual id:  0x21

$ export DISPLAY=:99 && google-chrome -start-maximized http://example.com > /dev/null &

$ ps auxx | grep 'chrome\|Xvfb' | grep -v grep
ubuntu   14843  0.0  0.4 193320 35308 pts/0    Sl   17:57   0:00 Xvfb :99 -screen 0 1024x768x24
ubuntu   14856  0.2  1.3 569044 108484 pts/0   Sl   17:58   0:01 /opt/google/chrome/chrome -start-maximized http://example.com
ubuntu   14868  0.0  0.6 358448 49424 pts/0    S    17:58   0:00 /opt/google/chrome/chrome --type=zygote
ubuntu   14869  0.0  0.1 142096  9596 pts/0    S    17:58   0:00 /opt/google/chrome/nacl_helper
ubuntu   14872  0.0  0.1 358448 11012 pts/0    S    17:58   0:00 /opt/google/chrome/chrome --type=zygote
ubuntu   14960  0.0  0.7 446888 64060 pts/0    Sl   17:58   0:00 /opt/google/chrome/chrome --type=gpu-process --channel=14856.0.2123468494 --window-depth=24 --supports-dual-gpus=false --gpu-driver-bug-workarounds=4,53 --disable-accelerated-video-decode --gpu-vendor-id=0x1013 --gpu-device-id=0x00b8 --gpu-driver-vendor --gpu-driver-version --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd

with xvfb-run

$ xvfb-run -a --server-args='-screen 0, 1024x768x24' google-chrome -start-maximized http://example.com > /dev/null &

$ ps auxx | grep 'chrome\|Xvfb' | grep -v grep
ubuntu    1196  0.0  0.0   4508  1644 pts/0    S    18:15   0:00 /bin/sh /usr/bin/xvfb-run -a --server-args=-screen 0, 1024x768x24 google-chrome -start-maximized http://example.com
ubuntu    1208  0.0  0.4 193192 35572 pts/0    Sl   18:15   0:00 Xvfb :99 -screen 0, 1024x768x24 -nolisten tcp -auth /tmp/xvfb-run.8pPvAX/Xauthority
ubuntu    1213  0.4  1.3 619068 106576 pts/0   Sl   18:15   0:00 /opt/google/chrome/chrome -start-maximized http://example.com
ubuntu    1224  0.0  0.5 358448 47768 pts/0    S    18:15   0:00 /opt/google/chrome/chrome --type=zygote
ubuntu    1225  0.0  0.1 142128  9600 pts/0    S    18:15   0:00 /opt/google/chrome/nacl_helper
ubuntu    1228  0.0  0.1 358448 10492 pts/0    S    18:15   0:00 /opt/google/chrome/chrome --type=zygote
ubuntu    1440  0.0  0.7 738140 62828 pts/0    Sl   18:15   0:00 /opt/google/chrome/chrome --type=renderer --lang=en-US --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-pinch --num-raster-threads=1 --content-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --video-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --disable-accelerated-video-decode --disable-webrtc-hw-encoding --disable-gpu-compositing --channel=1213.0.1322123415 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd

$ xdpyinfo -display :99
No protocol specified
xdpyinfo:  unable to open display ":99".

Note the difference in the Xvfb command that xvfb-run uses:

Xvfb :99 -screen 0, 1024x768x24 -nolisten tcp -auth /tmp/xvfb-run.8pPvAX/Xauthority

That is however not the problem since running it by itself and getting the display info works just fine.

1
  • I got this same problem: @TomSchober Have you managed to solve this? Could you post an answer?
    – Bartvds
    Nov 24, 2016 at 11:56

1 Answer 1

1

The obscure error message is because the client (xdpyinfo) doesn't have the correct authorization data.

As @TomSchober identified in the question, xvfb-run creates an authorization file with a path of the form /tmp/xvfb-run.XXXXXX/Xauthority and configures Xvfb to use that file. The clients need to use that file (rather than the default, which is ~/.Xauthority). This can be done by setting the XAUTHORITY environment variable:

DISPLAY=:99 XAUTHORITY=/tmp/xvfb-run.XXXXXX/Xauthority xdpyinfo

Here XXXXXX should be replaced to match the actual path. The path can be discovered by printing the arguments of the Xvfb process using pgrep -ax Xvfb and inspecting the value of the -auth option. Alternatively, xvfb-run has an option --auth-file that can be used to set the location of the Xauthority file (a warning will be printed if the file doesn't exist; you can ignore the warning, or create an empty file at that location beforehand).


An interesting observation that @TomSchober made in the question is that if you manually invoke the Xvfb command used by xvfb-run (that is, with the -auth option), it may be possible for clients to connect even if XAUTHORITY is not set. This is because xvfb-run adds an authorization entry to the Xauthority file before it runs Xvfb. If this entry is not added, and the file is empty/missing, Xvfb will allow clients to connect without requiring authorization (!). Xvfb only requires authorization if there is at least one entry in the Xauthority file. An authorization entry can be added manually using the following command:

XAUTHORITY=/path/to/Xauthority xauth source - <<EOF
add :99 . $(mcookie)
EOF

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .