resetting a stale VNC connection
Is there a monitor command (or other method) to force a VNC client connection to close?
It looks like the vnc code does not use keepalive probes. If the connection is left hanging the VNC server will never drop it. I have hit this condition a couple of times when a VPN connection drops while the vncviewer is connected to a VM.
Specific software version at the moment is kvm-81.
david
Quoted 10 lines · David S. Ahern
Is there a monitor command (or other method) to force a VNC client connection to close?
It looks like the vnc code does not use keepalive probes. If the connection is left hanging the VNC server will never drop it. I have hit this condition a couple of times when a VPN connection drops while the vncviewer is connected to a VM.
Specific software version at the moment is kvm-81.
Why not just enable tcp keepalives?
Signature · 1 line
error compiling committee.c: too many arguments to function
'egrep -r SO_KEEPALIVE qemu' did not turn up any hits for the VNC code. Can it be enabled within qemu via command line arg?
I am not aware of an OS setting to enable keepalives for all sockets. Is there one in RHEL5?
david
Quoted 14 lines · Avi Kivity
Quoted 10 lines · David S. Ahern
Is there a monitor command (or other method) to force a VNC client connection to close?
It looks like the vnc code does not use keepalive probes. If the connection is left hanging the VNC server will never drop it. I have hit this condition a couple of times when a VPN connection drops while the vncviewer is connected to a VM.
Specific software version at the moment is kvm-81.
Why not just enable tcp keepalives?
Quoted 3 lines · David S. Ahern
'egrep -r
SO_KEEPALIVEqemu' did not turn up any hits for the VNC code. Can it be enabled within qemu via command line arg?
It's not in the code AFAIK. I was suggesting to add it (unconditionally).
Quoted 3 lines
I am not aware of an OS setting to enable keepalives for all sockets. Is there one in RHEL5?
I don't think so. But enabling keepalives for vnc should be a one liner (or rather two, since we want to change the default interval).
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 11 lines · Avi Kivity
Quoted 2 lines · David S. Ahern
'egrep -r
SO_KEEPALIVEqemu' did not turn up any hits for the VNC code. Can it be enabled within qemu via command line arg?It's not in the code AFAIK. I was suggesting to add it (unconditionally).
Quoted 2 lines
I am not aware of an OS setting to enable keepalives for all sockets. Is there one in RHEL5?
I don't think so. But enabling keepalives for vnc should be a one liner (or rather two, since we want to change the default interval).
I think it should (also?) honor the 'shared desktop' flag.
Quoted 7 lines · Yaniv Kaul
Quoted 6 lines · Avi Kivity
Quoted 2 lines · David S. Ahern
'egrep -r
SO_KEEPALIVEqemu' did not turn up any hits for the VNC code. Can it be enabled within qemu via command line arg?It's not in the code AFAIK. I was suggesting to add it (unconditionally).
Ok, I misunderstood your last response. I'll add it, unconditionally.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
I am not aware of an OS setting to enable keepalives for all sockets. Is there one in RHEL5?
I don't think so. But enabling keepalives for vnc should be a one liner (or rather two, since we want to change the default interval).
What default interval would you prefer over the global values?
Quoted 2 lines
Quoted 1 line
I think it should (also?) honor the 'shared desktop' flag.
What do you mean by the 'shared desktop' flag?
david
Quoted 6 lines · David S. Ahern
Quoted 3 lines
Quoted 3 lines
I don't think so. But enabling keepalives for vnc should be a one liner (or rather two, since we want to change the default interval).
What default interval would you prefer over the global values?
The global one is two hours.
Say sending a probe every two seconds, failing if four probes don't come back?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 23 lines · David S. Ahern
Quoted 10 lines · Yaniv Kaul
Quoted 8 lines · Avi Kivity
Quoted 3 lines · David S. Ahern
'egrep -r
SO_KEEPALIVEqemu' did not turn up any hits for the VNC code. Can it be enabled within qemu via command line arg?It's not in the code AFAIK. I was suggesting to add it (unconditionally).
Ok, I misunderstood your last response. I'll add it, unconditionally.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
I am not aware of an OS setting to enable keepalives for all sockets. Is there one in RHEL5?
I don't think so. But enabling keepalives for vnc should be a one liner (or rather two, since we want to change the default interval).
Quoted 8 lines
What default interval would you prefer over the global values?
Quoted 2 lines
I think it should (also?) honor the 'shared desktop' flag.
What do you mean by the 'shared desktop' flag?
VNC clients send a flag called 'shared-flag' in their init message.
Quoted 1 line
From http://www.realvnc.com/docs/rfbproto.pdf , section 6.3.1 ClientInit:
Shared-flag is non-zero (true) if the server should try to share the desktop by leaving other clients connected, zero (false) if it should give exclusive access to this client by disconnecting all other clients.
Quoted 2 lines
david
Quoted 9 lines · Avi Kivity
Quoted 8 lines · David S. Ahern
Is there a monitor command (or other method) to force a VNC client connection to close?
It looks like the vnc code does not use keepalive probes. If the connection is left hanging the VNC server will never drop it. I have hit this condition a couple of times when a VPN connection drops while the vncviewer is connected to a VM.
Quoted 4 lines
Quoted 2 lines
Specific software version at the moment is kvm-81.
Why not just enable tcp keepalives?
Independant of killing off stale VNC clients, it could be desirable to have a monitor command to kill a client, to allow revoking of end user access to VNC.
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Quoted 15 lines · Daniel P. Berrange
Quoted 13 lines · Avi Kivity
Quoted 11 lines · David S. Ahern
Is there a monitor command (or other method) to force a VNC client connection to close?
It looks like the vnc code does not use keepalive probes. If the connection is left hanging the VNC server will never drop it. I have hit this condition a couple of times when a VPN connection drops while the vncviewer is connected to a VM.
Specific software version at the moment is kvm-81.
Quoted 7 lines
Quoted 2 lines
Why not just enable tcp keepalives?
Independant of killing off stale VNC clients, it could be desirable to have a monitor command to kill a client, to allow revoking of end user access to VNC.
I'm surprised change vnc none doesn't kill off all VNC connections.
I don't see a compelling use case to boot off individual clients other than we can. Is there something specific you were thinking someone would want to do?
Regards,
Anthony Liguori
Quoted 2 lines
Daniel
Quoted 19 lines · Anthony Liguori
Quoted 18 lines · Daniel P. Berrange
Quoted 15 lines · Avi Kivity
Quoted 11 lines · David S. Ahern
Is there a monitor command (or other method) to force a VNC client connection to close?
It looks like the vnc code does not use keepalive probes. If the connection is left hanging the VNC server will never drop it. I have hit this condition a couple of times when a VPN connection drops while the vncviewer is connected to a VM.
Specific software version at the moment is kvm-81.
Why not just enable tcp keepalives?
Quoted 6 lines
Quoted 4 lines
Independant of killing off stale VNC clients, it could be desirable to have a monitor command to kill a client, to allow revoking of end user access to VNC.
I'm surprised change vnc none doesn't kill off all VNC connections.
It may well do that - i've not tried it :-)
Quoted 3 lines
I don't see a compelling use case to boot off individual clients other than we can. Is there something specific you were thinking someone would want to do?
I've no pressing need for this - i was just thinking of possible use cases for the command. Now we allow multiple concurrent VNC clients, and can authenticate them, I just thought that it might be desirable to be able to drop individual authenticated clients. eg if you've revoked their credentials, but they still have a session open. Turning off+on the whole VNC server would work as a big stick too.
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
This patch enables TCP keepalives on VNC connections. After 60-seconds of idle time, probes are sent every 2 seconds with the connection resetting after 4 failed probes. This might be a rather aggressive setting -- 8 seconds until connection is reset.
Also, I believe this is a linux-specific way of doing this; not sure what the posix/windows method is. Open to suggestions.
Yaniv: I do not believe this interferes with the 'shared desktop'.
Quoted 5 lines · Avi Kivity
Quoted 4 lines · David S. Ahern
Quoted 3 lines
Quoted 3 lines
I don't think so. But enabling keepalives for vnc should be a one liner (or rather two, since we want to change the default interval).
Quoted 10 lines
Quoted 2 lines
What default interval would you prefer over the global values?
The global one is two hours.
Say sending a probe every two seconds, failing if four probes don't come back?
vnc.c +32 -0
@@ -32,6 +32,10 @@#define VNC_REFRESH_INTERVAL (1000 / 30) +#define VNC_TCP_KEEPIDLE 60 +#define VNC_TCP_KEEPINTVL 2 +#define VNC_TCP_KEEPCNT 4 +#include "vnc_keysym.h" #include "d3des.h"
@@ -2015,12 +2019,40 @@ static void vnc_listen_read(void *opaque)VncDisplay *vs = opaque;struct sockaddr_in addr;socklen_t addrlen =sizeof (addr); +int val;/* Catch-up */ vga_hw_update ();int csock =accept (vs->lsock, (struct sockaddr *)&addr, &addrlen);if (csock !=-1 ) { + +/* best effort to enable keep alives */ + val =1 ; +if (setsockopt (csock,SOL_SOCKET ,SO_KEEPALIVE , + &val,sizeof (val)) <0 ) { +fprintf (stderr,"VNC: failed to enable keepalives\n" ); + } + +/* after 60-seconds of idle time, send probes every 2 seconds +* dropping the connection after 4 failed probes +*/ + val =VNC_TCP_KEEPIDLE ; +if (setsockopt (csock,IPPROTO_TCP ,TCP_KEEPIDLE , + &val,sizeof (val)) <0 ) { +fprintf (stderr,"VNC: failed to set tcp idle interval\n" ); + } + val =VNC_TCP_KEEPINTVL ; +if (setsockopt (csock,IPPROTO_TCP ,TCP_KEEPINTVL , + &val,sizeof (val)) <0 ) { +fprintf (stderr,"VNC: failed to set tcp prove interval\n" ); + } + val =VNC_TCP_KEEPCNT ; +if (setsockopt (csock,IPPROTO_TCP ,TCP_KEEPCNT , + &val,sizeof (val)) <0 ) { +fprintf (stderr,"VNC: failed to set tcp prove interval\n" ); + } +vnc_connect (vs, csock); } }
Quoted 6 lines · David Ahern
This patch enables TCP keepalives on VNC connections. After 60-seconds of idle time, probes are sent every 2 seconds with the connection resetting after 4 failed probes. This might be a rather aggressive setting -- 8 seconds until connection is reset.
I think you are right, it's too aggressive. Maybe reduce it so it takes a minute until we give up.
Quoted 3 lines
Also, I believe this is a linux-specific way of doing this; not sure what the posix/windows method is. Open to suggestions.
At the very least, you need to wrap this in a #if defined(...) && defined (...) ... so it doesn't break compilation on hosts that don't support those socket options.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 19 lines · Daniel P. Berrange
Quoted 18 lines · Anthony Liguori
Quoted 17 lines · Daniel P. Berrange
Quoted 15 lines · Avi Kivity
Quoted 11 lines · David S. Ahern
Is there a monitor command (or other method) to force a VNC client connection to close?
It looks like the vnc code does not use keepalive probes. If the connection is left hanging the VNC server will never drop it. I have hit this condition a couple of times when a VPN connection drops while the vncviewer is connected to a VM.
Specific software version at the moment is kvm-81.
Why not just enable tcp keepalives?
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Independant of killing off stale VNC clients, it could be desirable to have a monitor command to kill a client, to allow revoking of end user access to VNC.
I'm surprised change vnc none doesn't kill off all VNC connections.
It may well do that - i've not tried it :-)
It did not kill off established connections for me; it closed the server socket, but not client connections.
david
Quoted 13 lines
Quoted 4 lines
I don't see a compelling use case to boot off individual clients other than we can. Is there something specific you were thinking someone would want to do?
I've no pressing need for this - i was just thinking of possible use cases for the command. Now we allow multiple concurrent VNC clients, and can authenticate them, I just thought that it might be desirable to be able to drop individual authenticated clients. eg if you've revoked their credentials, but they still have a session open. Turning off+on the whole VNC server would work as a big stick too.
Daniel
Quoted 8 lines · David S. Ahern
Quoted 2 lines · Daniel P. Berrange
It may well do that - i've not tried it :-)
It did not kill off established connections for me; it closed the server socket, but not client connections.
I'm really not sure if that's a bug or not. I think I could understand arguments for either behavior.
Regards,
Anthony Liguori
Quoted 1 line
david
Quoted 7 lines · Daniel P. Berrange
On Tue, Apr 21, 2009 at 11:49:11AM -0500, Anthony Liguori wrote:
I've no pressing need for this - i was just thinking of possible use cases for the command. Now we allow multiple concurrent VNC clients, and can authenticate them, I just thought that it might be desirable to be able to drop individual authenticated clients. eg if you've revoked their credentials, but they still have a session open. Turning off+on the whole VNC server would work as a big stick too.
I would link that to acl commands. You have to send that anyway to make qemu not accept new connections for $user. And qemu can check for open sessions owned by $user and zap them ...
cheers,
Gerd