Screenly OSE with VNC Viewer

I’m new to Balena and I have been trying to follow the tutorials given for multiple apps on one device. I am attempting to add a VNC viewer to my screenly deployment so I can embed it into a webpage. This will give me a live view of the assets on screen. However, I am struggling to implement this idea. I can get the vnc viewer to connect, but I just get a black screen. All help is appreciated.

Dockerfile:

FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:stretch-run

RUN install_packages x11vnc \
    x11-utils \
    xvfb \
    wmctrl \
    supervisor \
    x11vnc

WORKDIR /usr/src/app

COPY . .

ADD supervisor /etc/supervisor

CMD ["bash", "start.sh"]

Start:

#!/bin/bash

if [ -z ${VNC_PASS} ]; then
  echo "STARTING VNC WITHOUT PASSWORD"
  supervisord -c /etc/supervisor/supervisord_np.conf  
else
  echo "STARTING VNC WITH PASSWORD"
  supervisord -c /etc/supervisor/supervisord.conf
fi

Supervisor App:

[program:x11vnc]
environment=DISPLAY=:1
command=x11vnc

Supervisornp:

[supervisord]
nodaemon=true

[program:xvfb]
command=Xvfb :1 -screen 0 1280x720x24

[program:x11vnc]
command=x11vnc -shared -display :1 -oa /var/log/x11vnc.log
autostart=true
autorestart=true
startretries=10

[include]
files = /etc/supervisor/app.conf

Docker-compose

version: "2"
services:
  vnc-app:
    restart: always
    build: ./vnc-app
    ports:
      - "8080:5900"
  srly-ose-server:
    image: screenly/srly-ose-server
    build:
      context: .
      dockerfile: docker/Dockerfile.server
    environment:
      - HOME=/data
      - LISTEN=0.0.0.0
      - CELERY_BROKER_URL=redis://redis:6379/0
      - CELERY_RESULT_BACKEND=redis://redis:6379/0
    devices:
      - "/dev/vchiq:/dev/vchiq"
    restart: always
    volumes:
      - resin-data:/data
    labels:
      io.balena.features.supervisor-api: '1'

  srly-ose-viewer:
    image: screenly/srly-ose-viewer
    build:
      context: .
      dockerfile: docker/Dockerfile.viewer
    depends_on:
      - srly-ose-server
    environment:
      - HOME=/data
      - PORT=80
      - NOREFRESH=1
      - LISTEN=srly-ose-nginx
    privileged: true
    restart: always
    volumes:
      - resin-data:/data

  srly-ose-websocket:
    image: screenly/srly-ose-websocket
    build:
      context: .
      dockerfile: docker/Dockerfile.websocket
    depends_on:
      - srly-ose-server
    environment:
      - HOME=/data
      - LISTEN=0.0.0.0
    restart: always
    volumes:
      - resin-data:/data

  srly-ose-celery:
    image: screenly/srly-ose-celery
    build:
      context: .
      dockerfile: docker/Dockerfile.celery
    depends_on:
      - srly-ose-server
      - redis
    environment:
      - HOME=/data
      - CELERY_BROKER_URL=redis://redis:6379/0
      - CELERY_RESULT_BACKEND=redis://redis:6379/0
    devices:
      - "/dev/vchiq:/dev/vchiq"
    restart: always
    volumes:
      - resin-data:/data

  redis:
    image: screenly/srly-ose-redis
    build:
      context: .
      dockerfile: docker/Dockerfile.redis
    ports:
      - 127.0.0.1:6379:6379
    restart: always
    volumes:
      - redis-data:/var/lib/redis

  srly-ose-nginx:
    image: screenly/srly-ose-nginx
    build:
      context: .
      dockerfile: docker/Dockerfile.nginx
    ports:
      - 80:80
    environment:
      - HOME=/data
    depends_on:
      - srly-ose-server
      - srly-ose-websocket
    restart: always
    volumes:
      - resin-data:/data:ro

volumes:
    resin-data:
    redis-data:

Hope this helps break down the current situation.

Hey @jeremythomas welcome to the forums!

At first glance, it looks like you’re getting a blank screen because you’ve installed xvfb, a virtual framebuffer, and then are using VNC to connect and view that (empty) output. I expect that Screenly is continuing to render elsewhere, not on the virtual framebuffer.

If that is the case the options are to change your VNC server to point to the display (maybe 0?) where Screenly is being rendered, or to copy the output from one display to the virtual. I’m not sure how the internals of Screenly work, so unsure if this make sense or if there’s another way to achieve the same thing. @vpetersson might be able to offer some ideas here!

This may seem stupid, and again I’m new to this, but could I simply remove the calls to xvfb? Afterwords, I could attempt to find which screen Screenly is being rendered on?

Yeah, I don’t think you’ll need xvfb for this. I’m not sure without setting up and playing with it myself, but it may be as simple as using 0 as the display for the VNC server instead of 1?

So changing the supervisornp file to:

[supervisord]
nodaemon=true

[program:x11vnc]
command=x11vnc -display :0
autostart=true
autorestart=true
startretries=10

[include]
files = /etc/supervisor/app.conf

This gives me a continuous restart from the vnc-app.

 vnc-app  2021-08-17 16:10:56,335 INFO exited: x11vnc (exit status 1; not expected)
 vnc-app  2021-08-17 16:10:57,343 INFO spawned: 'x11vnc' with pid 120
 vnc-app  2021-08-17 16:10:58,380 INFO success: x11vnc entered RUNNING state, process has stayed 

Hi @jeremythomas ,

From looking through the screenly repository, it seems that they access the framebuffer directly to display their application? I don’t see the use of an X server anywhere in there.

If I am wrong: we have a recently project that might help you here with VNC though, it x11vnc and novnc to display the X server (I’m assuming running here in screenly). GitHub - balena-io-playground/xserver-web-vnc: Run a web VNC client to interact with and view your loc

– Flynn

If there is a better way to do it I’d be all ears! I am just trying to take the display from screenly and view it on a website. I just want to be able to preview the screen remotely when I am changing assets to make sure that everything uploaded correctly.

Attached are a picture of my application build, a copy of the docker-compose file, and a readout of the balenacloud terminal. I have successfully pushed the image but I am still having trouble accessing VNC through both the ip:9090 and a VNC viewer.

version: "2"
services:
  srly-ose-server:
    image: screenly/srly-ose-server
    build:
      context: .
      dockerfile: docker/Dockerfile.server
    environment:
      - HOME=/data
      - LISTEN=0.0.0.0
      - CELERY_BROKER_URL=redis://redis:6379/0
      - CELERY_RESULT_BACKEND=redis://redis:6379/0
    devices:
      - "/dev/vchiq:/dev/vchiq"
    restart: always
    volumes:
      - resin-data:/data
    labels:
      io.balena.features.supervisor-api: '1'

  srly-ose-viewer:
    image: screenly/srly-ose-viewer
    build:
      context: .
      dockerfile: docker/Dockerfile.viewer
    depends_on:
      - srly-ose-server
    environment:
      - HOME=/data
      - PORT=80
      - NOREFRESH=1
      - LISTEN=srly-ose-nginx
    privileged: true
    restart: always
    volumes:
      - resin-data:/data

  srly-ose-websocket:
    image: screenly/srly-ose-websocket
    build:
      context: .
      dockerfile: docker/Dockerfile.websocket
    depends_on:
      - srly-ose-server
    environment:
      - HOME=/data
      - LISTEN=0.0.0.0
    restart: always
    volumes:
      - resin-data:/data

  srly-ose-celery:
    image: screenly/srly-ose-celery
    build:
      context: .
      dockerfile: docker/Dockerfile.celery
    depends_on:
      - srly-ose-server
      - redis
    environment:
      - HOME=/data
      - CELERY_BROKER_URL=redis://redis:6379/0
      - CELERY_RESULT_BACKEND=redis://redis:6379/0
    devices:
      - "/dev/vchiq:/dev/vchiq"
    restart: always
    volumes:
      - resin-data:/data

  redis:
    image: screenly/srly-ose-redis
    build:
      context: .
      dockerfile: docker/Dockerfile.redis
    ports:
      - 127.0.0.1:6379:6379
    restart: always
    volumes:
      - redis-data:/var/lib/redis

  srly-ose-nginx:
    image: screenly/srly-ose-nginx
    build:
      context: .
      dockerfile: docker/Dockerfile.nginx
    ports:
      - 8080:80
    environment:
      - HOME=/data
    depends_on:
      - srly-ose-server
      - srly-ose-websocket
    restart: always
    volumes:
      - resin-data:/data:ro
  xserver:
    image: balenablocks/xserver
    restart: always
    privileged: true
    volumes:
      - 'xserver:/tmp/.X11-unix'
  xserver-web-vnc:
    build: .
    restart: always
    network_mode: host
    privileged: true
    volumes:
      - 'xserver:/tmp/.X11-unix'
    environment:
      WEB_PORT: 80
      DISABLE_PASSWORDS: true
volumes:
    resin-data:
    redis-data:
    data:
    xserver:

Here is a terminal readout of xserver-web-vnc

Restarting service 'xserver-web-vnc sha256:d28742d9fdb47519b2855dc3e3a3829f0ab06517a244d802f98d8b689a0978f7'
 xserver-web-vnc  Disabling password protection
 xserver-web-vnc  Enabling view-only mode
 xserver-web-vnc  
 xserver-web-vnc  #
 xserver-web-vnc  # Starting x11vnc
 xserver-web-vnc  #
 xserver-web-vnc  21/08/2021 02:46:24 passing arg to libvncserver: -listen
 xserver-web-vnc  21/08/2021 02:46:24 passing arg to libvncserver: localhost
 xserver-web-vnc  ###############################################################
 xserver-web-vnc  #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  **  WARNING  **  WARNING  **  WARNING  **  WARNING  **   @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@        YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!!        @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  This means anyone with network access to this computer   @#
 xserver-web-vnc  #@  may be able to view and control your desktop.            @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@ >>> If you did not mean to do this Press CTRL-C now!! <<< @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  You can create an x11vnc password file by running:       @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@       x11vnc -storepasswd password /path/to/passfile      @#
 xserver-web-vnc  #@  or   x11vnc -storepasswd /path/to/passfile               @#
 xserver-web-vnc  #@  or   x11vnc -storepasswd                                 @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  (the last one will use ~/.vnc/passwd)                    @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  and then starting x11vnc via:                            @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@      x11vnc -rfbauth /path/to/passfile                    @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  an existing ~/.vnc/passwd file from another VNC          @#
 xserver-web-vnc  #@  application will work fine too.                          @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  You can also use the -passwdfile or -passwd options.     @#
 xserver-web-vnc  #@  (note -passwd is unsafe if local users are not trusted)  @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  Make sure any -rfbauth and -passwdfile password files    @#
 xserver-web-vnc  #@  cannot be read by untrusted users.                       @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  Use x11vnc -usepw to automatically use your              @#
 xserver-web-vnc  #@  ~/.vnc/passwd or ~/.vnc/passwdfile password files.       @#
 xserver-web-vnc  #@  (and prompt you to create ~/.vnc/passwd if neither       @#
 xserver-web-vnc  #@  file exists.)  Under -usepw, x11vnc will exit if it      @#
 xserver-web-vnc  #@  cannot find a password to use.                           @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  Even with a password, the subsequent VNC traffic is      @#
 xserver-web-vnc  #@  sent in the clear.  Consider tunnelling via ssh(1):      @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@    http://www.karlrunge.com/x11vnc/#tunnelling            @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  Or using the x11vnc SSL options: -ssl and -stunnel       @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  Please Read the documentation for more info about        @#
 xserver-web-vnc  #@  passwords, security, and encryption.                     @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@    http://www.karlrunge.com/x11vnc/faq.html#faq-passwd    @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@  To disable this warning use the -nopw option, or put     @#
 xserver-web-vnc  #@  'nopw' on a line in your ~/.x11vncrc file.               @#
 xserver-web-vnc  #@                                                           @#
 xserver-web-vnc  #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
 xserver-web-vnc  ###############################################################
 xserver-web-vnc  21/08/2021 02:46:25 x11vnc version: 0.9.16 lastmod: 2019-01-05  pid: 10
 xserver-web-vnc  21/08/2021 02:46:26 Using X display :0
 xserver-web-vnc  21/08/2021 02:46:26 rootwin: 0x50f reswin: 0x600001 dpy: 0x9a4d6f70
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 ------------------ USEFUL INFORMATION ------------------
 xserver-web-vnc  21/08/2021 02:46:26 X DAMAGE available on display, using it for polling hints.
 xserver-web-vnc  21/08/2021 02:46:26   To disable this behavior use: '-noxdamage'
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26   Most compositing window managers like 'compiz' or 'beryl'
 xserver-web-vnc  21/08/2021 02:46:26   cause X DAMAGE to fail, and so you may not see any screen
 xserver-web-vnc  21/08/2021 02:46:26   updates via VNC.  Either disable 'compiz' (recommended) or
 xserver-web-vnc  21/08/2021 02:46:26   supply the x11vnc '-noxdamage' command line option.
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 Wireframing: -wireframe mode is in effect for window moves.
 xserver-web-vnc  21/08/2021 02:46:26   If this yields undesired behavior (poor response, painting
 xserver-web-vnc  21/08/2021 02:46:26   errors, etc) it may be disabled:
 xserver-web-vnc  21/08/2021 02:46:26    - use '-nowf' to disable wireframing completely.
 xserver-web-vnc  21/08/2021 02:46:26    - use '-nowcr' to disable the Copy Rectangle after the
 xserver-web-vnc  21/08/2021 02:46:26      moved window is released in the new position.
 xserver-web-vnc  21/08/2021 02:46:26   Also see the -help entry for tuning parameters.
 xserver-web-vnc  21/08/2021 02:46:26   You can press 3 Alt_L's (Left "Alt" key) in a row to 
 xserver-web-vnc  21/08/2021 02:46:26   repaint the screen, also see the -fixscreen option for
 xserver-web-vnc  21/08/2021 02:46:26   periodic repaints.
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 XFIXES available on display, resetting cursor mode
 xserver-web-vnc  21/08/2021 02:46:26   to: '-cursor most'.
 xserver-web-vnc  21/08/2021 02:46:26   to disable this behavior use: '-cursor arrow'
 xserver-web-vnc  21/08/2021 02:46:26   or '-noxfixes'.
 xserver-web-vnc  21/08/2021 02:46:26 using XFIXES for cursor drawing.
 xserver-web-vnc  21/08/2021 02:46:26 GrabServer control via XTEST.
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 Scroll Detection: -scrollcopyrect mode is in effect to
 xserver-web-vnc  21/08/2021 02:46:26   use RECORD extension to try to detect scrolling windows
 xserver-web-vnc  21/08/2021 02:46:26   (induced by either user keystroke or mouse input).
 xserver-web-vnc  21/08/2021 02:46:26   If this yields undesired behavior (poor response, painting
 xserver-web-vnc  21/08/2021 02:46:26   errors, etc) it may be disabled via: '-noscr'
 xserver-web-vnc  21/08/2021 02:46:26   Also see the -help entry for tuning parameters.
 xserver-web-vnc  21/08/2021 02:46:26   You can press 3 Alt_L's (Left "Alt" key) in a row to 
 xserver-web-vnc  21/08/2021 02:46:26   repaint the screen, also see the -fixscreen option for
 xserver-web-vnc  21/08/2021 02:46:26   periodic repaints.
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 XKEYBOARD: number of keysyms per keycode 7 is greater
 xserver-web-vnc  21/08/2021 02:46:26   than 4 and 51 keysyms are mapped above 4.
 xserver-web-vnc  21/08/2021 02:46:26   Automatically switching to -xkb mode.
 xserver-web-vnc  21/08/2021 02:46:26   If this makes the key mapping worse you can
 xserver-web-vnc  21/08/2021 02:46:26   disable it with the "-noxkb" option.
 xserver-web-vnc  21/08/2021 02:46:26   Also, remember "-remap DEAD" for accenting characters.
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 X FBPM extension not supported.
 xserver-web-vnc  21/08/2021 02:46:26 X display is capable of DPMS.
 xserver-web-vnc  21/08/2021 02:46:26 --------------------------------------------------------
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 Default visual ID: 0x21
 xserver-web-vnc  21/08/2021 02:46:26 Read initial data from X display into framebuffer.
 xserver-web-vnc  21/08/2021 02:46:26 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/7680
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 X display :0 is 32bpp depth=24 true color
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 Autoprobing TCP port 
 xserver-web-vnc  21/08/2021 02:46:26 Autoprobing selected TCP port 5900
 xserver-web-vnc  21/08/2021 02:46:26 Autoprobing TCP6 port 
 xserver-web-vnc  21/08/2021 02:46:26 Autoprobing selected TCP6 port 5900
 xserver-web-vnc  21/08/2021 02:46:26 listen6: bind: Address already in use
 xserver-web-vnc  21/08/2021 02:46:26 Not listening on IPv6 interface.
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  21/08/2021 02:46:26 Xinerama is present and active (e.g. multi-head).
 xserver-web-vnc  21/08/2021 02:46:26 Xinerama: number of sub-screens: 1
 xserver-web-vnc  21/08/2021 02:46:26 Xinerama: no blackouts needed (only one sub-screen)
 xserver-web-vnc  21/08/2021 02:46:26 
 xserver-web-vnc  
 xserver-web-vnc  X11 MIT Shared Memory Attach failed:
 xserver-web-vnc    Is your DISPLAY=:0 on a remote machine?
 xserver-web-vnc    Suggestion, use: x11vnc -display :0 ... for local display :0
 xserver-web-vnc  
 xserver-web-vnc  caught X11 error:
 xserver-web-vnc  21/08/2021 02:46:26 deleted 60 tile_row polling images.
 xserver-web-vnc  X Error of failed request:  BadAccess (attempt to access private resource denied)
 xserver-web-vnc    Major opcode of failed request:  130 (MIT-SHM)
 xserver-web-vnc    Minor opcode of failed request:  1 (X_ShmAttach)
 xserver-web-vnc    Serial number of failed request:  56
 xserver-web-vnc    Current serial number in output stream:  118
 xserver-web-vnc  /entry.sh: 37: -no6: not found
 xserver-web-vnc  
 xserver-web-vnc  #
 xserver-web-vnc  # Starting novnc
 xserver-web-vnc  #
 xserver-web-vnc  
 xserver-web-vnc  WebSocket server settings:
 xserver-web-vnc    - Listen on :80
 xserver-web-vnc    - Web server. Web root: /usr/share/novnc
 xserver-web-vnc    - No SSL/TLS support (no cert file)
 xserver-web-vnc  Traceback (most recent call last):
 xserver-web-vnc    File "/usr/bin/websockify", line 33, in <module>
 xserver-web-vnc      sys.exit(load_entry_point('websockify==0.9.0', 'console_scripts', 'websockify')())
 xserver-web-vnc    File "/usr/lib/python3/dist-packages/websockify/websocketproxy.py", line 726, in websockify_init
 xserver-web-vnc      server.start_server()
 xserver-web-vnc    File "/usr/lib/python3/dist-packages/websockify/websockifyserver.py", line 737, in start_server
 xserver-web-vnc      lsock = self.socket(self.listen_host, self.listen_port, False,
 xserver-web-vnc    File "/usr/lib/python3/dist-packages/websockify/websockifyserver.py", line 488, in socket
 xserver-web-vnc      sock.bind(addrs[0][4])
 xserver-web-vnc  OSError: [Errno 98] Address already in use

Also, when a url address video is playing, such as youtube, the sound plays, but the video no longer appears. In its place is a black mouse cursor. This tells me that the vnc program and screenly appear to be fighting each other.

@jeremythomas that would seem to be the case. I was mentioning xserver-web-vnc as an example to use, but you will need to remove the line WEB_PORT: 80 in the environment variables for the service (and it will default to 9090 after that).

I am assuming you are seeing a problem because screenly isn’t using an X server? (only made by assumption). I will try and set this up myself to see if I can find the issue, because other members of the screenly community seem to have reported x11vnc working. It might be out of date information, because when I go through the source code for screenly it looks like they have removed x11 as a display mechanism completely.

@nucleardreamer I just wanted to let you know that all your help is really appreciated! I’m not sure, I’ve just been trying to research on old articles and most of them are pretty dated. I’m still working on things on my end, but your help is really appreciated. If we get this figured out, I’d like to send a couple dollars your way. I know you don’t have to spend your time with this.

@jeremythomas no problem at all, and also no money needed! Everyone at Balena enjoys taking on challenges and questions here, even if it’s not directly related to our platform. After seeing that the screenly forums aren’t particularly helpful, hopefully this thread can help out other people searching for the same thing.

When I can get a suitable hardware setup going I will try and see what I see on my end.

@nucleardreamer Sorry it’s been a couple weeks since the last response, work and school have kept me pretty busy. I’m still not having any luck getting the viewer working, any luck on your end?

Has anyone found a resolution? I am having a similar issue.