novnc: προβολή της οθόνης μας σε οποιονδήποτε browser

Ξεκίνησε από alkisg, 22 Οκτ 2018, 12:32:36 ΜΜ

« προηγούμενο - επόμενο »

alkisg

Σενάριο: θέλουμε να προβάλλουμε την οθόνη του Ubuntu μας σε διάφορους clients, είτε στο τοπικό δίκτυο είτε μέσω διαδικτύου, χωρίς να τους ζαλίσουμε με εγκαταστάσεις προγραμμάτων. Δηλαδή οι clients να έχουν μόνο έναν browser σε οποιοδήποτε λειτουργικό σύστημα ή συσκευή (παίζει και με κινητά/tablets).

Εγκαθιστούμε το novnc είτε από το κέντρο λογισμικού είτε με την παρακάτω εντολή:
Κώδικας: Bash
sudo apt-get install --yes novnc x11vnc


(το x11vnc το έχουν ήδη βάλει τα sch-scripts, το έγραψα παραπάνω για σιγουριά)

Στη συνέχεια, όταν θέλουμε να προβάλλουμε την οθόνη μας, δίνουμε:
Κώδικας: Bash
x11vnc -localhost -rfbport 5901 -shared -forever -viewonly -nocursorshape -passwd qwer1234 & /usr/share/novnc/utils/launch.sh --vnc localhost:5901; fg


Αλλάξτε το passwd qwer1234 πιο πάνω σε κάτι άλλο.
Για να συνδεθούν οι χρήστες μας, θα πρέπει να έχουμε κάνει port forward τη θύρα 6080 στον router μας, και να τους δώσουμε ένα URL σαν το παρακάτω:
Κώδικας: Bash
http://1.2.3.4:6080/vnc.html?host=1.2.3.4&port=6080&resize=scale


Αντί για 1.2.3.4 βάλτε την εξωτερική IP σας. Οι χρήστες θα δουν μια ιστοσελίδα που τους ζητάει τον κωδικό, και όταν τον δώσουν, θα δουν την οθόνη μας.

Για τερματισμό των προβολών πατήστε δύο φορές Ctrl+C. Περισσότερες παράμετροι σχολιάζονται εδώ.

Δημήτρης Γκίνης

Θέλοντας να το δοκιμάσω, το έβαλα στο σπίτι.
Ακολούθησα τα βήματα που περιγράφεις και δοκίμασα να συνδεθώ από το κινητό (firefox και chrome) αλλά:
Στο κινητό μου βγάζει: Failed to connect to server (code:1006)
Στο pc:
Press Ctrl-C to exit


192.168.1.4 - - [22/Oct/2018 20:18:23] code 404, message File not found
192.168.1.4 - - [22/Oct/2018 20:18:23] code 404, message File not found
192.168.1.4 - - [22/Oct/2018 20:18:30] 192.168.1.4: Plain non-SSL (ws://) WebSocket connection
192.168.1.4 - - [22/Oct/2018 20:18:30] 192.168.1.4: Version hybi-13, base64: 'False'
192.168.1.4 - - [22/Oct/2018 20:18:30] 192.168.1.4: Path: '/websockify'
192.168.1.4 - - [22/Oct/2018 20:18:30] connecting to: localhost:5901
handler exception: [Errno 111] Connection refused


Έχω κάνει κάποιο λάθος;;

alkisg

Σαν να μην τρέχει το x11vnc. Επικόλλησε όλο το output για να δούμε αν η εκτέλεση του x11vnc παρήγαγε κάποιο λάθος.

Δημήτρης Γκίνης

Σαν να έχεις δίκιο, τώρα πρόσεξα ότι μολις τρέξω
x11vnc -localhost -shared -forever -viewonly -passwd 1234 & /usr/share/novnc/utils/launch.sh --vnc localhost:5901; fg

αναφέρει κάτι για το x11vnc, απλά το output της συγκεκριμένης είναι αρκετές γραμμές και δεν το είχα δει:
[1] 3311
22/10/2018 21:19:32 passing arg to libvncserver: -passwd
22/10/2018 21:19:32 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 3311
22/10/2018 21:19:32 Using X display :0.0
22/10/2018 21:19:32 rootwin: 0x108 reswin: 0x3c00001 dpy: 0x1e54910
22/10/2018 21:19:32 
22/10/2018 21:19:32 ------------------ USEFUL INFORMATION ------------------
Warning: could not find self.pem
Starting webserver and WebSockets proxy on port 6080
22/10/2018 21:19:32 X DAMAGE available on display, using it for polling hints.
22/10/2018 21:19:32   To disable this behavior use: '-noxdamage'
22/10/2018 21:19:32 
22/10/2018 21:19:32   Most compositing window managers like 'compiz' or 'beryl'
22/10/2018 21:19:32   cause X DAMAGE to fail, and so you may not see any screen
22/10/2018 21:19:32   updates via VNC.  Either disable 'compiz' (recommended) or
22/10/2018 21:19:32   supply the x11vnc '-noxdamage' command line option.
22/10/2018 21:19:32 
22/10/2018 21:19:32 Wireframing: -wireframe mode is in effect for window moves.
22/10/2018 21:19:32   If this yields undesired behavior (poor response, painting
22/10/2018 21:19:32   errors, etc) it may be disabled:
22/10/2018 21:19:32    - use '-nowf' to disable wireframing completely.
22/10/2018 21:19:32    - use '-nowcr' to disable the Copy Rectangle after the
22/10/2018 21:19:32      moved window is released in the new position.
22/10/2018 21:19:32   Also see the -help entry for tuning parameters.
22/10/2018 21:19:32   You can press 3 Alt_L's (Left "Alt" key) in a row to 
22/10/2018 21:19:32   repaint the screen, also see the -fixscreen option for
22/10/2018 21:19:32   periodic repaints.
22/10/2018 21:19:32 
22/10/2018 21:19:32 XFIXES available on display, resetting cursor mode
22/10/2018 21:19:32   to: '-cursor most'.
22/10/2018 21:19:32   to disable this behavior use: '-cursor arrow'
22/10/2018 21:19:32   or '-noxfixes'.
22/10/2018 21:19:32 using XFIXES for cursor drawing.
22/10/2018 21:19:32 GrabServer control via XTEST.
22/10/2018 21:19:32 
22/10/2018 21:19:32 Scroll Detection: -scrollcopyrect mode is in effect to
22/10/2018 21:19:32   use RECORD extension to try to detect scrolling windows
22/10/2018 21:19:32   (induced by either user keystroke or mouse input).
22/10/2018 21:19:32   If this yields undesired behavior (poor response, painting
22/10/2018 21:19:32   errors, etc) it may be disabled via: '-noscr'
22/10/2018 21:19:32   Also see the -help entry for tuning parameters.
22/10/2018 21:19:32   You can press 3 Alt_L's (Left "Alt" key) in a row to 
22/10/2018 21:19:32   repaint the screen, also see the -fixscreen option for
22/10/2018 21:19:32   periodic repaints.
22/10/2018 21:19:32 
22/10/2018 21:19:32 XKEYBOARD: number of keysyms per keycode 10 is greater
22/10/2018 21:19:32   than 4 and 153 keysyms are mapped above 4.
22/10/2018 21:19:32   Automatically switching to -xkb mode.
22/10/2018 21:19:32   If this makes the key mapping worse you can
22/10/2018 21:19:32   disable it with the "-noxkb" option.
22/10/2018 21:19:32   Also, remember "-remap DEAD" for accenting characters.
22/10/2018 21:19:32 
22/10/2018 21:19:32 X FBPM extension not supported.
22/10/2018 21:19:32 X display is capable of DPMS.
22/10/2018 21:19:32 --------------------------------------------------------
22/10/2018 21:19:32 
22/10/2018 21:19:32 Default visual ID: 0x21
22/10/2018 21:19:32 Read initial data from X display into framebuffer.
22/10/2018 21:19:32 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/5120
22/10/2018 21:19:32 
22/10/2018 21:19:32 X display :0.0 is 32bpp depth=24 true color
22/10/2018 21:19:32 
22/10/2018 21:19:32 Autoprobing TCP port 
22/10/2018 21:19:32 Autoprobing selected TCP port 5900
22/10/2018 21:19:32 Autoprobing TCP6 port 
22/10/2018 21:19:32 Autoprobing selected TCP6 port 5900
22/10/2018 21:19:32 listen6: bind: Address already in use
22/10/2018 21:19:32 Not listening on IPv6 interface.
22/10/2018 21:19:32 
22/10/2018 21:19:32 Xinerama is present and active (e.g. multi-head).
22/10/2018 21:19:32 Xinerama: number of sub-screens: 1
22/10/2018 21:19:32 Xinerama: no blackouts needed (only one sub-screen)
22/10/2018 21:19:32 
22/10/2018 21:19:32 fb read rate: 1396 MB/sec
22/10/2018 21:19:32 fast read: reset -wait  ms to: 10
22/10/2018 21:19:32 fast read: reset -defer ms to: 10
22/10/2018 21:19:32 The X server says there are 20 mouse buttons.
22/10/2018 21:19:32 screen setup finished.
22/10/2018 21:19:32 

The VNC desktop is:      localhost:0
PORT=5900

******************************************************************************
Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?

The scheme stores pixel data offscreen on the VNC viewer side for faster
retrieval.  It should work with any VNC viewer.  Try it by running:

    x11vnc -ncache 10 ...

One can also add -ncache_cr for smooth 'copyrect' window motion.
More info: http://www.karlrunge.com/x11vnc/faq.html#faq-client-caching

WebSocket server settings:
  - Listen on :6080
  - Flash security policy server
  - Web server. Web root: /usr/share/novnc
  - No SSL/TLS support (no cert file)
  - proxying from :6080 to localhost:5901


Navigate to this URL:


alkisg

ΟΚ δικό μου το λάθος, επειδή είχα ήδη ένα VNC ανοιχτό αυτό ήταν το δεύτερο και πήγαινε μόνο του στην 5901 θύρα.
Ενημέρωσα την εντολή παραπάνω με -rfbport 5901, θα πρέπει να είναι εντάξει τώρα...