vnc issue after reboot

Hi ,

Everytime after reboot when user tries to start vnc below error is thrown

$ vncserver :5
Couldn't start Xvnc; trying default font path.
Please set correct fontPath in the vncserver script.
Couldn't start Xvnc process.

_XSERVTransSocketCreateListener: failed to bind listener
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for local

Fatal server error:
Failed to establish all listening sockets
_XSERVTransSocketCreateListener: failed to bind listener
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for local

Fatal server error:
Failed to establish all listening sockets

It works after removing .X11* files under /tmp . But want to know why this is happening after each reboot and we have to remove these files manually after which user is able to start the session.

A script is seen under /etc/rc2.d which has the below content

#!/sbin/sh

mkdir /tmp/.X11-unix /tmp/.X11-pipe 2>/dev/null
chmod 1777 /tmp/.X11-unix /tmp/.X11-pipe

There are options to tell vnc to use just tcp/ip sockets. Since you are usually not local, that is fine. It takes the first one it can bind(). Look around in vncserver perl.

sorry but can you please explain me what is the reason of this error and is there any fix for this and why this happens only after reboot.

I am using solaris 10

There are two families of sockets X supports, AF_UNIX and AF_INET, see man 2 socket. AF_UNIX only works locally but AF_INET works on the internet. The files are markers for the AF_UNIX listeners, and should be removed on reboot but apparently are not. I usually have too little access to remove them, anyway. I had a similar error before, so I went into vncserver, a perl script, and discovered how to make it just test AF_UNIX. Oh look what google found: Unix - VNC

Thanks to you , i didnt know that vncserver was a perl script. i will try this option next time.

vncserver -nolisten local

Btw.. can you please tell me what should i edit in the perl script so that a execution of "vncserver" command the system should automatically pick "-nolisten local" as parmaters.

Just set the underlying variable to 1 as default. My vncserver is older, has no option, but look for this:

# If the unix domain socket exists then use that (DISPLAY=:n) otherwise use
# TCP (DISPLAY=host:n)
if (-e "/tmp/.X11-unix/X$displayNumber" ||
    -e "/usr/spool/sockets/X11/$displayNumber")
{
    $ENV{DISPLAY}= ":$displayNumber";
} else {
    $ENV{DISPLAY}= "$host:$displayNumber";
}
$ENV{VNCDESKTOP}= $desktopName;
system("$vncUserDir/xstartup >> " . &quotedString($desktopLog) . " 2>&1 &");
"vncserver" line 190

vncserver just finds an open port and calls Xvnc, so you can call it yourself.

Hi ,

Should i replace $displayNumber in the above lines to 1 or should i declare the value of displayNumber=1 in the start of the script ?

It's not the display number that is an issue, just let it find an open one, but my vncserver gets chatty along the way. That option is passed to Xvnc, apparently:

$ vncserver -h
usage: vncserver [:<number>] [-name <desktop-name>] [-depth <depth>]
                 [-geometry <width>x<height>]
                 [-pixelformat rgbNNN|bgrNNN]
                 <Xvnc-options>...
       vncserver -kill <X-display>
 
$
 
 
 
#
# CheckDisplayNumber checks if the given display number is available.  A
# display number n is taken if something is listening on the VNC server port
# (5900+n) or the X server port (6000+n).
#
sub CheckDisplayNumber
{
    local ($n) = @_;
    socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n";
    eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))';
    if (!bind(S, pack('S n x12', $AF_INET, 6000 + $n))) {
        close(S);
        return 0;
    }
    close(S);
    socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n";
    eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))';
    if (!bind(S, pack('S n x12', $AF_INET, 5900 + $n))) {
        close(S);
        return 0;
    }
    close(S);
    if (-e "/tmp/.X$n-lock") {
        warn "\nWarning: $host:$n is taken because of /tmp/.X$n-lock\n";
        warn "Remove this file if there is no X server $host:$n\n";
        return 0;
    }
    if (-e "/tmp/.X11-unix/X$n") {
        warn "\nWarning: $host:$n is taken because of /tmp/.X11-unix/X$n\n";
        warn "Remove this file if there is no X server $host:$n\n";
        return 0;
    }
    if (-e "/usr/spool/sockets/X11/$n") {
        warn("\nWarning: $host:$n is taken because of ".
             "/usr/spool/sockets/X11/$n\n");
        warn "Remove this file if there is no X server $host:$n\n";
        return 0;
    }
    return 1;
}