VNC Viewer request timeout solution, gray screen solution (gnome or xfce4)

VNC Viewer request timeout

question

Prompt when connecting:Timed out waiting for a response from the computer

Insert image description here

When connecting to the virtual desktop through VNC Viewer, a connection timeout occurs. Generally, if this problem occurs, first consider whether it is caused by 服务器IPor VNC端口号input error.
After troubleshooting, it was confirmed that the IP and port numbers were correct. After trying various methods, the problem was discovered:

The server may have a firewall turned on, and some services cannot be accessed through the server's external IP, causing the connection to time out.

solution

You only need to manually open the corresponding port number in the server, and VNC Viewer can access it.

First check the current firewall rules:

#查看当前的规则和对应的编号,需要使用root权限
sudo iptables -L -n --line-number 

Insert image description here
There are many rules below. The two ports in the picture are VNC-related ports. One is the port of desktop No. 52, and the other is the port of desktop No. 9. The previous rules only have rules for 09. 52 in the picture is Added later.

Since the port of desktop 52 was not opened in the previous rules, it was opened manually.
First, you need to obtain the port number of desktop No. 52. The default port of VNC starts from 5901, that is, the port number of desktop No. 1 is 5901, and the corresponding port number of desktop No. 52 is 5952. If you are not sure or to be safe, you can use the following Use the command to view all VNC port numbers under a personal user.

netstat -lp|grep -i vnc

Insert image description here
It can be obtained that the port number of desktop 52 is: 5952

Then, manually open the rules for port 52 and add the command to the firewall rules as follows:

sudo iptables -I INPUT -p tcp --dport 5952 -j ACCEPT

After opening the port, VNC Viewer can access the VNC corresponding to port 52.

gnome desktop gray screen

Note: The installation in the gnome environment may not be successful. If your system is 16.04 or 18.04, just turn back and see the xfce4 solution.
After opening the desktop, the screen is gray, the mouse is in an 'X' shape, and no operations can be performed.
Insert image description here
If you have configured the xstartup file before and it is running normally, you can try the command to install the packages required by gnome, or update these packages.

sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

After installation or update, if the screen is still gray, it means there is a problem with xstartup.

We open amax-sys:52.logthe file and view the desktop log:

Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc


Mon Nov  8 14:25:29 2021
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on port 5952
 vncext:      created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
sh: /home/liushuo/.vnc/xstartup: Permission denied

From the last sentence, we get that the permissions of the xstartup file are insufficient. Check the permissions of xstartup:
Insert image description here

You can see that xstartup only has read and write permissions, so we add execution permissions to xstartup.

chmod +x .vnc/xstartup

Insert image description here
Then regenerate desktop number 52

vncserver -kill :52
vncserver -geometry 1920x1080 :52

After opening the desktop, the menu bar can be displayed normally, and the program and terminal can run normally. However, the desktop and icons cannot be displayed, and the program runs very slowly.
Insert image description here

View the log file:

Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc


Mon Nov  8 17:17:22 2021
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on port 5951
 vncext:      created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
/home/liushuo/.vnc/xstartup: line 16: gnome-settings-daemon: command not found
metacity-Message: 17:17:25.351: could not find XKB extension.

The reason is that there is no gnome-settings-daemon command, that is, gnome-settings-daemon was not installed successfully.
I installed it through apt-get without any problems, but ps -A | grep gnomeI couldn't find the gnome-settings-daemon information through.
Insert image description here
I've been working on it for a long time and I don't know where the problem lies. Anyone who knows the solution can share it.
My xstartup content is as follows:

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

# dbus-launch startxfce4
 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
 
xsetroot -solid grey
vncconfig -iconic &
 
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

If your gnome-settings-daemon is normal, the desktop should appear after modifying the permissions of xstartup.
If you have the same problem as me and the Ubuntu system is 16.04 or 18.04, you can choose to install another desktop environment: Xfce4.

xfce4 solution

The installation method is also very simple. The default system here has vncserver installed. If it is not installed, use the following command to install it:

sudo apt-get install vnc4server

Then install xfce

sudo apt-get install xfce4

You can use the following command to check whether the installation is successful:

ps -A | grep xfce4

Insert image description here
Modify the configuration file xstartup to:

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

dbus-launch startxfce4

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
xrdb $HOME/.Xresources

Then regenerate desktop No. 52

vncserver -kill :52
vncserver -geometry 1920x1080 :52

Insert image description here
Attached is the log file of VNC currently in normal use:


Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc


Mon Nov  8 19:08:30 2021
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on port 5951
 vncext:      created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
/usr/bin/startxfce4: X server already running on display :51
gpg-agent[42352]: WARNING: "--write-env-file" is an obsolete option - it has no effect
gpg-agent: a gpg-agent is already running - not starting a new one

(xfce4-session:42337): xfce4-session-WARNING **: 19:08:34.025: gpg-agent returned no PID in the variables

(xfce4-session:42337): xfce4-session-WARNING **: 19:08:34.026: xfsm_manager_load_session: Something wrong with /home/liushuo/.cache/sessions/xfce4-session-amax-sys:51, Does it exist? Permissions issue?
vmware-user: could not open /proc/fs/vmblock/dev

(xfwm4:42355): xfwm4-WARNING **: 19:08:34.063: The display does not support the XRender extension.

(xfwm4:42355): xfwm4-WARNING **: 19:08:34.063: The display does not support the XComposite extension.

(xfwm4:42355): xfwm4-WARNING **: 19:08:34.063: The display does not support the XDamage extension.

(xfwm4:42355): xfwm4-WARNING **: 19:08:34.064: The display does not support the XFixes extension.

(xfwm4:42355): xfwm4-WARNING **: 19:08:34.064: Compositing manager disabled.

(xfsettingsd:42371): xfsettingsd-CRITICAL **: 19:08:34.076: RANDR extension is too old, version 1.1. Display settings won't be applied.
Xlib:  extension "XInputExtension" missing on display ":51.0".

(xfsettingsd:42371): xfsettingsd-CRITICAL **: 19:08:34.076: XI is not present.

(xfsettingsd:42371): xfsettingsd-CRITICAL **: 19:08:34.076: Failed to initialize the Xkb extension.

(xfsettingsd:42371): xfsettingsd-CRITICAL **: 19:08:34.076: Failed to initialize the Accessibility extension.

** (update-notifier:42372): WARNING **: 19:08:34.100: already running?
xfwm4-Message: 19:08:34.112: Unsupported keyboard modifier '<Super>Tab'

(polkit-gnome-authentication-agent-1:42374): GLib-CRITICAL **: 19:08:34.115: g_variant_new_string: assertion 'string != NULL' failed

(polkit-gnome-authentication-agent-1:42374): polkit-gnome-1-WARNING **: 19:08:34.116: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

(xfwm4:42355): xfwm4-WARNING **: 19:08:34.117: Cannot find visual format on screen 0
xfwm4-Message: 19:08:34.160: Unsupported keyboard modifier '<Super>Tab'

(nm-applet:42367): nm-applet-WARNING **: 19:08:34.220: GDBus.Error:org.freedesktop.NetworkManager.AgentManager.PermissionDenied: An agent with this ID is already registered for this user.

(nm-applet:42367): Gtk-WARNING **: 19:08:34.255: Can't set a parent on widget which has a parent
Failure: Module initialization failed

** (xfdesktop:42363): WARNING **: 19:08:34.472: Failed to set the background '/usr/share/backgrounds/xfce/xfce-teal.jpg': GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: No such interface 'org.freedesktop.DisplayManager.AccountsService'

There are still some caveats, but the desktop is ready to use.

reference

Port:
https://www.jianshu.com/p/b3068288d80d
https://www.cnblogs.com/ding2016/p/8031926.html

VNC error troubleshooting:
https://blog.csdn.net/CH_sir/article/details/107930881
https://junchu.blog.csdn.net/article/details/103974974
https://blog.csdn.net/qq695165856/ article/details/105677776

Gray screen:
https://www.freesion.com/article/85721281890/

xfce4:
https://www.cnblogs.com/kerrycode/p/4790021.html
https://blog.csdn.net/weixin_34174422/article/details/93689750
https://www.linuxidc.com/Linux/2018-08/153435.htm

Guess you like

Origin blog.csdn.net/qq_41340996/article/details/121210273
Recommended