# Xfce4 is not displayed correctly when I connect vncviewer (in Linux) to tightvnc-server (on FreeBSD)



## ziomario (Jul 1, 2022)

Hello.

I have installed *tigervnc-server* on my FreeBSD 13.1-RELEASE with the command :


```
pkg install tigervnc-server
```

and I've created this config file :


```
nano /home/marietto/.vnc/xstartup
```


```
!/bin/sh
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
exec startxfce4 &

but I tried also with exec xfce4-session &
```

and I tried to connect to it using vncviewer installed on Linux Ubuntu (virtualized with bhyve),but something is not good because I see only a black screen,as you can see below. Do you know why ?






I've even tried to run the vnc-viewer on my other PC (connected to the same LAN),running Windows and I see the same black screen.

On FreeBSD I use xfce4 as default,infact I have created this conf file that works ok :


```
nano /home/marietto/.xinitrc

setxkbmap it
exec ck-launch-session dbus-launch --exit-with-session startxfce4
```

I've realized that the folder */etc/vnc *is empty on my side and the xstartup script is on Linux. I don't know if it works also on FreeBSD.


----------



## Phishfry (Jul 1, 2022)

How about trying this:
`startxfce4 --with-ck-launch`

I doubt ck or polkit is the problem. Have you checked your log.
Chances are its an authentication problem.


----------



## ziomario (Jul 2, 2022)

your solution does not work....


```
sh: /home/marietto/.vnc/xstartup: Permission denied : fixed

/etc/X11/xinit/xinitrc : not found : not fixed.
```

I have two options here :


```
/usr/local/etc/xdg/xfce4/xinitrc
/usr/local/etc/X11/xinit/xinitrc
```


----------



## CuatroTorres (Jul 2, 2022)

I haven't used it in years, try to run it with minimal specs:

vncserver :0 -geometry 1920x1080 -depth 24

The display manager can also play tricks on you.


----------



## ziomario (Jul 2, 2022)

CuatroTorres said:


> I haven't used it in years, try to run it with minimal specs:
> 
> vncserver :0 -geometry 1920x1080 -depth 24
> 
> The display manager can also play tricks on you.



vncserver :5 -geometry 1024x768 -depth 24 = blackscreen


----------



## ziomario (Jul 2, 2022)

xfce4-session-Message: 13:28:38.823: SSH authentication agent is already running


----------



## T-Daemon (Jul 2, 2022)

ziomario said:


> nano /home/marietto/.vnc/xstartup





ziomario said:


> !/bin/sh
> unset SESSION_MANAGER
> exec /etc/X11/xinit/xinitrc
> 
> ...



Try `dbus-launch startxfce4` ( from archlinux forum: VNC with Xfce problem).



ziomario said:


> !/bin/sh


The number sign (#) in the shebang is missing. Got it lost during copy & paste or is it missing in real?


----------



## ziomario (Jul 2, 2022)

the sign # was a typo. This is the xstartup file that I'm using :


```
#!/bin/sh

unset SESSION_MANAGER
exec /usr/local/etc/xdg/xfce4/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#exec startxfce4 --with-ck-launch &
dbus-launch startxfce4
```

It does not work. Again black screen. But :

1) on /etc/vnc I have placed the xstartup file that you find on linux when you install vncserver,this : https://paste.ubuntu.com/p/hPF5mv93XQ/
2) on my FreeBSD at $HOME,there isn't any .Xresources file. Maybe it wants .Xauthority ?


----------



## CuatroTorres (Jul 2, 2022)

2) touch ~/.Xresources






						TightVNC - ParabolaWiki
					






					wiki.parabola.nu


----------



## ziomario (Jul 2, 2022)

```
mario@marietto:/etc/vnc # x11vnc -geometry 1024x768

###############################################################
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                           @#
#@  **  WARNING  **  WARNING  **  WARNING  **  WARNING  **   @#
#@                                                           @#
#@        YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!!        @#
#@                                                           @#
#@  This means anyone with network access to this computer   @#
#@  may be able to view and control your desktop.            @#
#@                                                           @#
#@ >>> If you did not mean to do this Press CTRL-C now!! <<< @#
#@                                                           @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                           @#
#@  You can create an x11vnc password file by running:       @#
#@                                                           @#
#@       x11vnc -storepasswd password /path/to/passfile      @#
#@  or   x11vnc -storepasswd /path/to/passfile               @#
#@  or   x11vnc -storepasswd                                 @#
#@                                                           @#
#@  (the last one will use ~/.vnc/passwd)                    @#
#@                                                           @#
#@  and then starting x11vnc via:                            @#
#@                                                           @#
#@      x11vnc -rfbauth /path/to/passfile                    @#
#@                                                           @#
#@  an existing ~/.vnc/passwd file from another VNC          @#
#@  application will work fine too.                          @#
#@                                                           @#
#@  You can also use the -passwdfile or -passwd options.     @#
#@  (note -passwd is unsafe if local users are not trusted)  @#
#@                                                           @#
#@  Make sure any -rfbauth and -passwdfile password files    @#
#@  cannot be read by untrusted users.                       @#
#@                                                           @#
#@  Use x11vnc -usepw to automatically use your              @#
#@  ~/.vnc/passwd or ~/.vnc/passwdfile password files.       @#
#@  (and prompt you to create ~/.vnc/passwd if neither       @#
#@  file exists.)  Under -usepw, x11vnc will exit if it      @#
#@  cannot find a password to use.                           @#
#@                                                           @#
#@                                                           @#
#@  Even with a password, the subsequent VNC traffic is      @#
#@  sent in the clear.  Consider tunnelling via ssh(1):      @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/#tunnelling            @#
#@                                                           @#
#@  Or using the x11vnc SSL options: -ssl and -stunnel       @#
#@                                                           @#
#@  Please Read the documention for more info about          @#
#@  passwords, security, and encryption.                     @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/faq.html#faq-passwd    @#
#@                                                           @#
#@  To disable this warning use the -nopw option, or put     @#
#@  'nopw' on a line in your ~/.x11vncrc file.               @#
#@                                                           @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
###############################################################
02/07/2022 14:58:05 x11vnc version: 0.9.16 lastmod: 2019-01-05  pid: 13251
02/07/2022 14:58:05 Using X display :0.0
02/07/2022 14:58:05 rootwin: 0x755 reswin: 0x3600001 dpy: 0x1453000
02/07/2022 14:58:05 
02/07/2022 14:58:05 ------------------ USEFUL INFORMATION ------------------
02/07/2022 14:58:05 X DAMAGE available on display, using it for polling hints.
02/07/2022 14:58:05   To disable this behavior use: '-noxdamage'
02/07/2022 14:58:05 
02/07/2022 14:58:05   Most compositing window managers like 'compiz' or 'beryl'
02/07/2022 14:58:05   cause X DAMAGE to fail, and so you may not see any screen
02/07/2022 14:58:05   updates via VNC.  Either disable 'compiz' (recommended) or
02/07/2022 14:58:05   supply the x11vnc '-noxdamage' command line option.
02/07/2022 14:58:05 
02/07/2022 14:58:05 Wireframing: -wireframe mode is in effect for window moves.
02/07/2022 14:58:05   If this yields undesired behavior (poor response, painting
02/07/2022 14:58:05   errors, etc) it may be disabled:
02/07/2022 14:58:05    - use '-nowf' to disable wireframing completely.
02/07/2022 14:58:05    - use '-nowcr' to disable the Copy Rectangle after the
02/07/2022 14:58:05      moved window is released in the new position.
02/07/2022 14:58:05   Also see the -help entry for tuning parameters.
02/07/2022 14:58:05   You can press 3 Alt_L's (Left "Alt" key) in a row to 
02/07/2022 14:58:05   repaint the screen, also see the -fixscreen option for
02/07/2022 14:58:05   periodic repaints.
02/07/2022 14:58:05   Note: '-scale' is on and this can cause more problems.
02/07/2022 14:58:05 
02/07/2022 14:58:05 XFIXES available on display, resetting cursor mode
02/07/2022 14:58:05   to: '-cursor most'.
02/07/2022 14:58:05   to disable this behavior use: '-cursor arrow'
02/07/2022 14:58:05   or '-noxfixes'.
02/07/2022 14:58:05 using XFIXES for cursor drawing.
02/07/2022 14:58:05 GrabServer control via XTEST.
02/07/2022 14:58:05 
02/07/2022 14:58:05 Scroll Detection: -scrollcopyrect mode is in effect to
02/07/2022 14:58:05   use RECORD extension to try to detect scrolling windows
02/07/2022 14:58:05   (induced by either user keystroke or mouse input).
02/07/2022 14:58:05   If this yields undesired behavior (poor response, painting
02/07/2022 14:58:05   errors, etc) it may be disabled via: '-noscr'
02/07/2022 14:58:05   Also see the -help entry for tuning parameters.
02/07/2022 14:58:05   You can press 3 Alt_L's (Left "Alt" key) in a row to 
02/07/2022 14:58:05   repaint the screen, also see the -fixscreen option for
02/07/2022 14:58:05   periodic repaints.
02/07/2022 14:58:05   Note: '-scale' is on and this can cause more problems.
02/07/2022 14:58:05 
02/07/2022 14:58:05 XKEYBOARD:
02/07/2022 14:58:05 Switching to -xkb mode to recover these keysyms:
02/07/2022 14:58:05    xkb  noxkb   Keysym  ("X" means present)
02/07/2022 14:58:05    ---  -----   -----------------------------
02/07/2022 14:58:05     X           0x40  at
02/07/2022 14:58:05     X           0x23  numbersign
02/07/2022 14:58:05     X           0x5b  bracketleft
02/07/2022 14:58:05     X           0x5d  bracketright
02/07/2022 14:58:05     X           0x7b  braceleft
02/07/2022 14:58:05     X           0x7d  braceright
02/07/2022 14:58:05 
02/07/2022 14:58:05   If this makes the key mapping worse you can
02/07/2022 14:58:05   disable it with the "-noxkb" option.
02/07/2022 14:58:05 
02/07/2022 14:58:05 
02/07/2022 14:58:05 X FBPM extension not supported.
02/07/2022 14:58:05 X display is capable of DPMS.
02/07/2022 14:58:05 --------------------------------------------------------
02/07/2022 14:58:05 
02/07/2022 14:58:05 Default visual ID: 0x21
02/07/2022 14:58:05 Read initial data from X display into framebuffer.
02/07/2022 14:58:05 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/7680
02/07/2022 14:58:05 scaling screen: 1920x1080 -> 1024x768
02/07/2022 14:58:05 scaling screen: scale_fac_x=0.53333 scale_fac_y=0.71111
02/07/2022 14:58:05 
02/07/2022 14:58:05 X display :0.0 is 32bpp depth=24 true color
02/07/2022 14:58:05 
02/07/2022 14:58:05 Autoprobing TCP port 
02/07/2022 14:58:05 Autoprobing selected TCP port 5900
02/07/2022 14:58:05 Autoprobing TCP6 port 
02/07/2022 14:58:05 Autoprobing selected TCP6 port 5900
02/07/2022 14:58:05 listen6: bind: Address already in use
02/07/2022 14:58:05 Not listening on IPv6 interface.
02/07/2022 14:58:05 
02/07/2022 14:58:05 Xinerama is present and active (e.g. multi-head).
02/07/2022 14:58:05 Xinerama: number of sub-screens: 1
02/07/2022 14:58:05 Xinerama: no blackouts needed (only one sub-screen)
02/07/2022 14:58:05 
02/07/2022 14:58:05 fb read rate: 1439 MB/sec
02/07/2022 14:58:05 fast read: reset -wait  ms to: 10
02/07/2022 14:58:05 fast read: reset -defer ms to: 10
02/07/2022 14:58:05 The X server says there are 12 mouse buttons.
02/07/2022 14:58:05 screen setup finished.
02/07/2022 14:58:05 
02/07/2022 14:58:05 WARNING: You are running x11vnc WITHOUT a password.  See
02/07/2022 14:58:05 WARNING: the warning message printed above for more info.
02/07/2022 14:58:05 

The VNC desktop is:      marietto: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

02/07/2022 14:58:37 Got connection from client 192.168.1.4
02/07/2022 14:58:37   0 other clients
02/07/2022 14:58:37 Disabled X server key autorepeat.
02/07/2022 14:58:37   to force back on run: 'xset r on' (3 times)
02/07/2022 14:58:37 incr accepted_client=1 for 192.168.1.4:56886  sock=10
02/07/2022 14:58:37 Client Protocol Version 3.8
02/07/2022 14:58:37 Protocol version sent 3.8, using 3.8
02/07/2022 14:58:37 rfbProcessClientSecurityType: executing handler for type 1
02/07/2022 14:58:37 rfbProcessClientSecurityType: returning securityResult for client rfb version >= 3.8
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC6)
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0x574D5664)
02/07/2022 14:58:37 Enabling full-color cursor updates for client 192.168.1.4
02/07/2022 14:58:37 Enabling X-style cursor updates for client 192.168.1.4
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0x574D5666)
02/07/2022 14:58:37 Enabling NewFBSize protocol extension for client 192.168.1.4
02/07/2022 14:58:37 Enabling ExtDesktopSize protocol extension for client 192.168.1.4
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFECD)
02/07/2022 14:58:37 Enabling LastRect protocol extension for client 192.168.1.4
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xC0A1E5CE)
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC7)
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC8)
02/07/2022 14:58:37 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEFE)
02/07/2022 14:58:37 Using compression level 2 for client 192.168.1.4
02/07/2022 14:58:37 Using image quality level 8 for client 192.168.1.4
02/07/2022 14:58:37 Using JPEG subsampling 0, Q92 for client 192.168.1.4
02/07/2022 14:58:37 Using tight encoding for client 192.168.1.4
02/07/2022 14:58:37 Sending rfbEncodingExtDesktopSize for size (1024x768) 
02/07/2022 14:58:38 client_set_net: 192.168.1.4  0.0152
02/07/2022 14:58:38 created   xdamage object: 0x3600040
02/07/2022 14:58:38 copy_tiles: allocating first_line at size 61
02/07/2022 14:58:38 client 1 network rate 15493.5 KB/sec (256100.1 eff KB/sec)
02/07/2022 14:58:38 client 1 latency:  0.5 ms
02/07/2022 14:58:38 dt1: 0.0025, dt2: 0.0031 dt3: 0.0005 bytes: 83420
02/07/2022 14:58:38 link_rate: LR_LAN - 1 ms, 15493 KB/s
02/07/2022 14:58:47 created selwin: 0x3600041
02/07/2022 14:58:47 called initialize_xfixes()
02/07/2022 14:58:47 client_count: 0
02/07/2022 14:58:47 Restored X server key autorepeat to: 1
02/07/2022 14:58:47 viewer exited.
02/07/2022 14:58:47 deleted 60 tile_row polling images.
```

it worked partially. Unfortunately this is what happens when I connect the server with the client :


----------



## CuatroTorres (Jul 2, 2022)

Infinite nested windows when connecting through VNC
					

I am trying to connect to my VNC server that i have setup in my ubuntu 16.04 i have tried the default out of the box vnc server Desktop-Sharing i have tried x11vnc. When i connect the connection wo...




					askubuntu.com


----------



## ziomario (Jul 2, 2022)

I'm running FreeBSD as host os (with IP = 192.168.1.2), within which I'm running a Linux VM (with IP = 192.168.1.4), and in the Linux VM I'm running a VNC viewer which I connect to FreeBSD... IP numbers are different,OS are different. I don't understand why I get the "infinite nested windows" problem. Is there a method to fix it ? On the article posted they don't talk about a solution.


----------



## ziomario (Jul 2, 2022)

```
mario@marietto:~/.vnc # touch ~/.Xresources
ok

/home/marietto/.vnc/xstartup :

#!/bin/sh

unset SESSION_MANAGER
exec /usr/local/etc/xdg/xfce4/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
dbus-launch startxfce4
```

Log :


```
Xvnc TigerVNC 1.12.0 - built Jun 30 2022 00:07:36
Copyright (C) 1999-2021 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12014000, The X.Org Foundation


Sat Jul  2 16:22:04 2022
vncext:      VNC extension running!
vncext:      Listening for VNC connections on all interface(s), port 5901
vncext:      created VNC server for screen 0
Error creating proxy: The connection is closed (g-io-error-quark, 18)

Sat Jul  2 16:22:20 2022
Connections: accepted: 192.168.1.4::51198
SConnection: Client needs protocol version 3.8
SConnection: Client requests security type VeNCrypt(19)
SVeNCrypt:   Client requests security type TLSVnc (258)

Sat Jul  2 16:22:25 2022
VNCSConnST:  Server default pixel format depth 24 (32bpp) little-endian rgb888
```

I see some progress but not yet done :


----------



## ziomario (Jul 2, 2022)

I tried all of these combinations,none of them worked :


```
#exec startxfce4 --with-ck-launch &
#dbus-launch startxfce4
#exec xfce4-session --with-ck-launch &
#exec startxfce4 &
#exec xfce4-session &
#exec ck-launch-session dbus-launch --exit-with-session startxfce4
```


----------



## fraxamo (Jul 2, 2022)

ziomario said:


> I tried all of these combinations,none of them worked :


Can you try the following:

```
exec /usr/local/bin/startxfce4 --with-ck-launch
```
You don't need the ampersand (&) at the end of the line that starts your WM, only on the application(s) that you want to start in the background.


----------



## ziomario (Jul 2, 2022)

Nope. The error reported by the log file is :

*Error creating proxy: The connection is closed (g-io-error-quark, 18)*


----------



## eternal_noob (Jul 2, 2022)

Looks like recursion to me.


----------



## ziomario (Jul 2, 2022)

eternal_noob said:


> Looks like recursion to me.



what is this ?


----------



## eternal_noob (Jul 2, 2022)

http://rubidium.negative273.com/images/recursive.jpg


----------



## ziomario (Jul 2, 2022)

eternal_noob said:


> http://rubidium.negative273.com/images/recursive.jpg



I've understood this,but I have no idea about how to fix it. What I want to do is only to display the freebsd desktop inside the Linux VM window.


----------



## eternal_noob (Jul 3, 2022)

Maybe the server connects to itself? And again and again. Recursion.


----------



## ziomario (Jul 3, 2022)

Ip numbers are different,OSes are different...


----------



## JoshS (Jul 6, 2022)

For what it's worth, I had similar issues setting up VNC on Linux recently with tigervnc-server.  Switched to tightvnc-server and everything works like it should.


----------



## ziomario (Jul 6, 2022)

I don't find the package *tightvnc-server* from packages. I have only this package : *tightvnc: 1.3.10_6* and I presume that's the client.


----------

