X process block socket

Hi there,

I try to setup Remote administration with x0vncserver but I get an error message in local.
When I start x0vncserver in the remote, I get “failed to bind socket: Address already in use (98)”

x0vncserver -passwordfile ~/.vnc/passwd -display :0
Invalid MIT-MAGIC-COOKIE-1 key
Sun Dec 13 11:13:31 2020
 Geometry:    Desktop geometry is set to 1280x800+0+0
 XDesktop:    Using evdev codemap

 XDesktop:    XTest extension present - version 2.2
 XDesktop:    RANDR extension not present
 XDesktop:    Will not be able to handle session resize
 Main:        failed to bind socket: Address already in use (98)

sudo ss -tulpn | grep :5900
tcp    LISTEN     0      5      0.0.0.0:5900               0.0.0.0:*                   users:(("X",pid=1319,fd=18))
tcp    LISTEN     0      5      ::]:5900               ::]:*                   users:(("X",pid=1319,fd=19))

 ls /proc | less
....
root      1319  1.5  2.5 576592 88604 tty7     Ssl+ 09:06   1:01 /usr/bin/X :0 -seat seat0 -auth /run/lightdm/root/:
....

On another computer running fine x0vncserver this last command return

root      1945  1.3  3.3 550336 67828 tty7     Ssl+ 09:26   1:26 /usr/bin/X :0 -seat seat0 -auth /run/lightdm/root/: -nolisten tcp vt7 -novtswitch

Something happened and removed the /usr/bin/X command parameters.
How could I add them again?

Thanks

First, a general observation… x0vncserver is generally not recommended (of the 3 main ways to deploy vnc) because it does not perform as well as the others. You might deploy x0vncserver only if you are just more familiar with setting it up over the others.

If you want to look at what is recommended, the openSUSE documentation describes how to set up xvnc which is generally recommended

https://doc.opensuse.org/documentation/leap/reference/html/book-opensuse-reference/cha-vnc.html

Note that it’s recommended to install and start vncserver using YaST so that you are set up with a standard and expected working configuration that anyone who might help you should be familiar with. Again though, it would mean you aren’t running x0vncserver.

Although the error only refers to a socket error,
An Internet search returns only network socket issues, so it’s a good assumption that something else is already running using the same network socket(network address including port assignment).
Are you sure you’re not also running a web server on the machine which might create a conflict connecting using the web client?
How are you starting up your x0vncserver?

The references I generally use regarding x0vncserver are

https://wiki.archlinux.org/index.php/TigerVNC
https://tigervnc.org/doc/x0vncserver.html

TSU

AFAIK, x0vncserver is the only way to not create a new display but use the display created by the user in the remote computer.
If there is another way (it should be very recent) please let me know.

I can’t see any web server. Do you have a command line to check for sure? I never setup that.
I set the password with

vncpasswd

then I start it with

x0vncserver -passwordfile ~/.vnc/passwd -display :0

I use https://www.howtoforge.com/tutorial/how-to-start-a-vnc-server-for-the-actual-display-scraping-with-tigervnc/
Thank you for your help

More info

> cat /var/log/Xorg.0.log | grep vnc
    37.744] (II) LoadModule: "vnc"
    37.760] (II) Loading /usr/lib64/xorg/modules/extensions/libvnc.so
    37.818] (II) Module vnc: vendor="TigerVNC Project"

On the working computer this command returns nothing.
How can I configure X server?

No guarantees, but sometimes a bad entry in “.Xauthority” can cause similar problems. If you suspect that, the remove “.Xauthority” then immediately logout and login again. That causes “.Xauthority” to be regenerated.

If I want to remove “.Xauthority”, I usually logout from the graphic session and them remove it from a command line login. That’s safer.

Unfortunately, still the same issue.

Some questions:

  • Is the command hard coded with the parameters at boot?
  • Is there a config file?
  • How to modify the first or the second above?

Typically, “failed to bind socket: Address already in use” means that the server is already running, though it could also be caused by programming errors.

Since that is happening on the remote server, it might be harder to investigate.

More info:
In /etc/X11/xinit/xserverrc I have:

# handle TCP port 6000
. /etc/sysconfig/displaymanager
if test "$DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN" != "yes" ; then
    args="$args -nolisten tcp"
fi
....
    exec X $dspnum -auth $auth $args
else
    exec X $dspnum $args
fi

In the on working computer, then answer of test is not “yes”

Any help?

More info

> cat /etc/sysconfig/displaymanager
## Path:        Desktop/Display manager
## Type:        string(Xorg)
## Default:     "Xorg"
#
DISPLAYMANAGER_XSERVER="Xorg"
## Path:    Desktop/Display manager
## Description:    settings to generate a proper displaymanager config

## Type:    string(kdm,xdm,gdm,wdm,entrance,console,lightdm,sddm)
## Default:    ""
#
# Here you can set the default Display manager (kdm/xdm/gdm/wdm/entrance/console).
# all changes in this file require a restart of the displaymanager
#
DISPLAYMANAGER="lightdm"
## Path:    Desktop/Display manager
## Description:    settings to generate a proper displaymanager config
## Type:    yesno
## Default:    no
#
# Allow remote access (XDMCP) to your display manager (xdm/kdm/gdm). Please note
# that a modified kdm or xdm configuration, e.g. by KDE control center
# will not be changed. For gdm, values will be updated after change.
# XDMCP service should run only on trusted networks and you have to disable
# firewall for interfaces, where you want to provide this service.
#
DISPLAYMANAGER_REMOTE_ACCESS="no"

## Type:    yesno
## Default:    no
#
# Allow remote access of the user root to your display manager. Note
# that root can never login if DISPLAYMANAGER_SHUTDOWN is "auto" and
# System/Security/Permissions/PERMISSION_SECURITY is "paranoid"
#
DISPLAYMANAGER_ROOT_LOGIN_REMOTE="no"

## Type:    yesno
## Default:    yes
#
# Let the displaymanager start a local Xserver.
# Set to "no" for remote-access only.
# Set to "no" on architectures without any Xserver (e.g. s390/s390x).
#
DISPLAYMANAGER_STARTS_XSERVER="yes"

## Type:        yesno
## Default:     no
#
# TCP port 6000 of Xserver. When set to "no" (default) Xserver is
# started with "-nolisten tcp". Only set this to "yes" if you really
# need to. Remote X service should run only on trusted networks and
# you have to disable firewall for interfaces, where you want to
# provide this service. Use ssh X11 port forwarding whenever possible.
#
**DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN="no"
**
## Type:    string
## Default:
#
# Define the user whom should get logged in without request. If string
# is empty, display standard login dialog.
#
DISPLAYMANAGER_AUTOLOGIN="xx"

## Type:        yesno
## Default:     no
#
# Allow all users to login without password, but ask for the user, if
# DISPLAYMANAGER_AUTOLOGIN is empty.
#
DISPLAYMANAGER_PASSWORD_LESS_LOGIN="no"

## Type:        yesno
## Default:     no
#
# Display a combobox for Active Directory domains.
#
DISPLAYMANAGER_AD_INTEGRATION="no"

## Type:    list(root,all,none,auto)
## Default: auto
#
# Determine who will be able to shutdown or reboot the system in kdm.  Valid
# values are: "root" (only root can shutdown), "all" (everybody can shutdown),
# "none" (nobody can shutdown from displaymanager), "auto" (follow
# System/Security/Permissions/PERMISSION_SECURITY to decide: "easy local" is
# equal to "all", everything else is equal to "root").  gdm respects the
# PolicyKit settings for ConsoleKit. Shutdown configuration can be done via
# the polkit-default-privs mechanism.
#
DISPLAYMANAGER_SHUTDOWN="auto"


DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN="no"
I can’t understand, “-nolisten tcp” should be added to the command.
I don’t want to reinstall now,
I need help!!!

New info.
For some reason I get now in prosess list

root      1382  1.0  1.9 477552 68632 tty7     Ssl+ 12:06   0:21 /usr/bin/X :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch

:question:
But still the

> x0vncserver -passwordfile ~/.vnc/passwd -display :0
...
 XDesktop:    Will not be able to handle session resize
 Main:        failed to bind socket: Address already in use (98)

Slightly off topic to your efforts to get x0vncserver working (I’ll respond to that in a separate post after reviewing your guide and everything posted here so far), the following are answers to this post about setting up “normal” xvnc instead of x0vncserver

When you set up xvnc, you can set up support for two types of connections… “one time” connections which do not support sharing the Desktop of the interactively logged in User and “persistent connections” which does. If you installed the VNC using the YaST module, you’ll also have a nice graphical tool where you can set up the necessary options for either type of connections, see the screenshot of the following section of the openSUSE documentation. I wouldn’t say this info is “very recent” but it is authoritative, current and has always worked.

https://doc.opensuse.org/documentation/leap/reference/html/book-opensuse-reference/cha-vnc.html#sec-vnc-persistent

Checking for the existence of a running webserver is not difficult, just telnet or less optimally point web browser to that address, eg

telnet 127.0.0.1 443

Try the following command instead

x0vncserver -passwordfile ~/.vnc/passwd -display **localhost**:0

TSU

Thank you tsu2 for your advice.

~> x0vncserver -passwordfile ~/.vnc/passwd -display localhost:0
x0vncserver: unable to open display "localhost:0"

As I wrote previously, I have 2 remote computers, one working with x0vncserver the other not working with x0vncserver.

I’ll try to replace x0vncserver by “xvnc” on the working one.
What I did:
In the remote computer
Menu>Yast>Network services>Remote administration(vnc)
Select:

  • Allow remote admin with session management
  • Open port in firewall
  • Next
    Restart

In the local computer
Menu>Internet>Remote desktop viewer
Connect, Protocol:VNC, host:remote 192.168.1.116, Connect
Error message: "Connection to host 192.168.1.116 was closed
Other try:
Connect, Protocol:VNC, host:remote 192.168.1.116:5901, Connect
A bip happen in the remote
Error message: "Connection to host 192.168.1.116 was closed
I closed the viewer

Menu>Internet>Tiger vnc viewer
VNC server: 192.168.1.116, Connect
Error message: "unable connect to socket: Connection refused (111)

In the remote, from CLI:

> sudo lsof -i -P -n | grep LISTEN
....
vncmanage 2792  vnc  5u  IPv4  43246  0t0  *:5901  (LISTEN)
vncmanage 2792  vnc  6u  IPv6  43247  0t0  *:5901  (LISTEN)

From local:
Menu>Internet>Tiger vnc viewer
VNC server: 192.168.1.116:5901, Connect
A bip happen in the remote
Error message: “Could not acquire name on session bus. Close”
From CLI

> vncviewer 192.168.1.116:5901

TigerVNC Viewer 64-bit v1.9.0
Copyright (C) 1999-2018 TigerVNC Team and many others (see README.rst)
See http://www.tigervnc.org for information on TigerVNC.

Sat Dec 19 08:54:08 2020
 DecodeManager: Detected 8 CPU core(s)
 DecodeManager: Creating 4 decoder thread(s)
 CConn:       connected to host 192.168.1.116 port 5901
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
 CConnection: Choosing security type VeNCrypt(19)
 CVeNCrypt:   Choosing security type TLSNone (257)

Sat Dec 19 08:54:10 2020
 CConn:       Using pixel format depth 24 (32bpp) little-endian rgb888
 CConn:       Using Tight encoding

As this issue is time consuming, could you be very accurate in the process.

  • Are all needed packages installed by default? If not, what is/are the exact package name(s) I have to install? There is no package named “xvnc”
  • Is it the exact way I used to set up the server?
  • How to debug further?

I don’t want to reinstall from scratch.
Somebody to help me?

Hi tsu2,
After long time to test different ways to get it working, I am afraid your above assertion is not true. AFAIK, the GUI run vncserver. In the man pages of vncserver, one can read:

vncserver can be run with no options at all. In this case it will choose the first available display number (usually :1), start Xvnc with that display number, and start the default window manager in the Xvnc session. You can also specify the display number, in which case vncserver will attempt to start Xvnc with that display number and exit if the display number is not available

It will never use the existing/running local user display and there is no option for that. You can try this if your runnung display is :0

vncserver :0

You will get an error message.

As said in [this thread

](VNCserver vs VNCmanager persistant - Network/Internet - openSUSE Forums)

**So, the ONLY WAY to share the existing, running local user display is to start x0vncserver from the CLI.
**

Now I have to find out why I can’t connect to my second computer with x0vncserver.

I start over with x0vncserver

> x0vncserver -passwordfile ~/.vnc/passwd -display :0
No protocol specified

Sun Dec 27 07:03:42 2020
 Geometry:    Desktop geometry is set to 1280x800+0+0
 XDesktop:    Using evdev codemap

 XDesktop:    XTest extension present - version 2.2
 XDesktop:    RANDR extension not present
 XDesktop:    Will not be able to handle session resize
 Main:        **failed to bind socket: Address already in use (98)**

> sudo ss -tulpn | grep :5900
[sudo] password for root: 
tcp    LISTEN     0      5      0.0.0.0:5900               0.0.0.0:*                   users:(("X",pid=1416,fd=18))
tcp    LISTEN     0      5      ::]:5900               ::]:*                   users:(("X",pid=1416,fd=19))

> sudo lsof -i -P -n | grep LISTEN
.....
X         1416  root   18u  IPv4  30171      0t0  TCP *:5900 (LISTEN)
X         1416  root   19u  IPv6  30172      0t0  TCP *:5900 (LISTEN)

> ps aux | grep 1416
root      1416  0.6  1.8 487328 63228 tty7     Ssl+ 07:02   0:28 **/usr/bin/X :0** -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch

Why X is listening? On my working computer, X is not listening when x0vncserver is not running. When I start x0vncserver, x0vncserver is listening at :5900
How to debug?
Many thanks

It is listening because you told it to load vnc module that implements VNC server inside of X server (it may be considered “embedded x0vncserver”).

I’d say I did a mistake but I don’t know when and where.
How to tell it to NOT load vnc module?

You simply do NOT tell it to load module. Look in /etc/X11/xorg.conf and /etc/X11/xorg.conf.d if some configuration file loads it.

> cat /etc/X11/xorg.conf
cat: /etc/X11/xorg.conf: No such file or directory

> cat /etc/X11/xorg.conf.d/10-vnc.conf
Section "Module"
Load "vnc"
EndSection

Section "Screen"
Identifier "Screen0"
Option "UserPasswdVerifier" "VncAuth"
Option "PasswordFile" "/root/.vnc/passwd"
EndSection

I’d guess I should remove /etc/X11/xorg.conf.d/10-vnc.conf
What is the best, proper way to do?

rm /etc/X11/xorg.conf.d/10-vnc.conf

??
And by the way what was the command that added this file in xorg.conf.d directory?