TigerVNC / tigervnc

High performance, multi-platform VNC client and server
https://tigervnc.org
GNU General Public License v2.0
5.11k stars 936 forks source link

TigerVNC server keeps disconnecting even with all flags of idle disabled #1353

Closed caio-vinicius closed 3 years ago

caio-vinicius commented 3 years ago

Describe the bug I have a TigerVNC server running in a ubuntu 20.04 environment that is running very good, but always keep disconnecting with 1 minute of idle time. I already try to use and set all the Xvnc flags for idle to 0:

-IdleTimeout 0 -MaxDisconnectionTime 0 -MaxConnectionTime 0 -MaxIdleTime 0

And even so I keep being disconnected from the server. Also, I was checking if was not the screensaver that was causing the issue (I'm using Xfce), and disabled it and the problem keeps.

To Reproduce

  1. Download https://deac-fra.dl.sourceforge.net/project/tigervnc/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz
  2. Install TigerVNC
  3. Initiate "vncserver $DISPLAY -Log *:syslog:100 -IdleTimeout 0 -MaxDisconnectionTime 0 -MaxConnectionTime 0 -MaxIdleTime 0 -depth $VNC_COL_DEPTH -geometry $VNC_RESOLUTION"
  4. Connect to it
  5. After 1 minute without interaction, the connection is dropped

Expected behavior The connection remain connected without being dropped

Client (please complete the following information):

Server (please complete the following information):

caio-vinicius commented 3 years ago

Tried with 3600 seconds instead of 0, the problem persists.

CendioOssman commented 3 years ago

Could you proivde a server log of when this happens? That should show us why the connection is dropped. You should find the log in ~/.vnc.

I also saw you commenting on #586. Did it help forcing a TCP keep-alive?

caio-vinicius commented 3 years ago

I will get the logs in .vnc folder.

I tried use libkeepalive, but this didn't work. I don't really know if I set it up correctly though.

Another information that could be useful: I'm behind a firewall and inside a K8s cluster, so with some configurations until really reach the final client using the VNC Client.

I see that in TAG v1.11.90 (https://github.com/TigerVNC/tigervnc/releases/tag/v1.11.90), there's a bullet describing:

This is related in anyway with the -IdleTimeout (and similar, for idle monitoring) features?

caio-vinicius commented 3 years ago
Xvnc TigerVNC 1.10.0 - built Dec 20 2019 07:12:07
Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12001000, The X.Org Foundation

Thu Oct 14 19:51:12 2021
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on all interface(s), port 5901
 vncext:      created VNC server for screen 0

Thu Oct 14 19:51:50 2021
 Connections: accepted: 192.168.78.0::23637
 SConnection: Client needs protocol version 3.8
 SConnection: Client requests security type VeNCrypt(19)
 SVeNCrypt:   Client requests security type TLSVnc (258)

Thu Oct 14 19:51:53 2021
 VNCSConnST:  Server default pixel format depth 24 (32bpp) little-endian rgb888
 VNCSConnST:  Client pixel format depth 24 (32bpp) little-endian rgb888

Thu Oct 14 19:53:00 2021
 VNCSConnST:  closing 192.168.78.0::23637: Clean disconnection
 EncodeManager: Framebuffer updates: 12
 EncodeManager:   ZRLE:
 EncodeManager:     Indexed RLE: 6 rects, 370.384 kpixels
 EncodeManager:                  26.9639 KiB (1:53.6601 ratio)
 EncodeManager:     Full Colour: 29 rects, 1.08437 Mpixels
 EncodeManager:                  407.101 KiB (1:10.4057 ratio)
 EncodeManager:   Total: 35 rects, 1.45476 Mpixels
 EncodeManager:          434.064 KiB (1:13.0926 ratio)
 TLS:         TLS session wasn't terminated gracefully
 TcpSocket:   unable to get peer name for socket
 Connections: closed: ::0
 ComparingUpdateTracker: 254.76 kpixels in / 143.876 kpixels out
 ComparingUpdateTracker: (1:1.77069 ratio)

~/.vnc logs from a start connection until it drops.

caio-vinicius commented 3 years ago

Using "RealVNC Viewer" 6.21.406 (r44671) x64 (Apr 7 2021 10:26:26)

Thu Oct 14 20:01:28 2021
 Connections: accepted: 192.168.78.0::48237
 SConnection: Client needs protocol version 3.8
 SConnection: Client requests security type VncAuth(2)

Thu Oct 14 20:01:35 2021
 VNCSConnST:  Server default pixel format depth 24 (32bpp) little-endian rgb888
 VNCSConnST:  Client pixel format depth 6 (8bpp) rgb222

Thu Oct 14 20:02:50 2021
 VNCSConnST:  closing 192.168.78.0::48237: Clean disconnection
 EncodeManager: Framebuffer updates: 8
 EncodeManager:   RRE:
 EncodeManager:     Solid: 9 rects, 446.032 kpixels
 EncodeManager:            153 B (1:2915.95 ratio)
 EncodeManager:   ZRLE:
 EncodeManager:     Bitmap RLE: 1 rects, 160 pixels
 EncodeManager:                 58 B (1:2.96552 ratio)
 EncodeManager:     Indexed RLE: 18 rects, 887.92 kpixels
 EncodeManager:                  22.8174 KiB (1:38.0114 ratio)
 EncodeManager:   Total: 28 rects, 1.33411 Mpixels
 EncodeManager:          23.0234 KiB (1:56.602 ratio)
 TcpSocket:   unable to get peer name for socket
 Connections: closed: ::0
 ComparingUpdateTracker: 2.66573 Mpixels in / 10.56 kpixels out
 ComparingUpdateTracker: (1:252.436 ratio)
caio-vinicius commented 3 years ago

Remmina, same version as the issue but starting vncserver with "-SecurityTypes None". Still disconnected.

Xvnc TigerVNC 1.10.0 - built Dec 20 2019 07:12:07
Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12001000, The X.Org Foundation

Thu Oct 14 20:16:07 2021
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on all interface(s), port 5901
 vncext:      created VNC server for screen 0

Thu Oct 14 20:17:28 2021
 Connections: accepted: 10.51.4.23::52511
 SConnection: Client needs protocol version 3.8
 SConnection: Client requests security type None(1)
 VNCSConnST:  Server default pixel format depth 24 (32bpp) little-endian rgb888
 VNCSConnST:  Client pixel format depth 24 (32bpp) little-endian rgb888

Thu Oct 14 20:18:50 2021
 VNCSConnST:  closing 10.51.4.23::52511: Clean disconnection
 EncodeManager: Framebuffer updates: 4
 EncodeManager:   ZRLE:
 EncodeManager:     Indexed RLE: 5 rects, 309.76 kpixels
 EncodeManager:                  23.0059 KiB (1:52.5978 ratio)
 EncodeManager:     Full Colour: 21 rects, 1.0031 Mpixels
 EncodeManager:                  390.028 KiB (1:10.047 ratio)
 EncodeManager:   Total: 26 rects, 1.31286 Mpixels
 EncodeManager:          413.034 KiB (1:12.4171 ratio)
 TcpSocket:   unable to get peer name for socket
 Connections: closed: ::0
 ComparingUpdateTracker: 39.68 kpixels in / 1.984 kpixels out
 ComparingUpdateTracker: (1:20 ratio)
caio-vinicius commented 3 years ago

In Ubuntu 20.04, net-tools 2.10-alpha netstat -nputw:

"Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name" Before connection being dropped: tcp 0 0 192.168.0.118:59688 1x.x.x.x:30019 ESTABLISHED 2696987/remmina After connection being dropped: tcp 0 0 192.168.0.118:59688 1x.x.x.x:30019 CLOSE_WAIT 2696987/remmina

caio-vinicius commented 3 years ago

Also, find out this issue in kubernetes repository: https://github.com/kubernetes/kubernetes/issues/80298

This is any way could be related to use of IPVS (Linux Virtual Server administration)?

Output of timeout in ipvsadm (I'm using kube-proxy with ipvs instead of iptables)

ipvsadm -l --timeout 
Timeout (tcp tcpfin udp): 900 120 300

Output of https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/usingkeepalive.html

cat /proc/sys/net/ipv4/tcp_keepalive_time
7200
cat /proc/sys/net/ipv4/tcp_keepalive_intvl
75
cat /proc/sys/net/ipv4/tcp_keepalive_probes
9

Let me know if this question run away of the topic of this discussion, since it's already related to my current environment of running TigerVNC.

caio-vinicius commented 3 years ago

Just found out: I'm running HAProxy in front of my connection and the timeout is 50s. This was the problem. Solved changing to 2m.

Thanks for your time @CendioOssman