From e6cb79b52c387ef6b266f81b2b75bfb3a0adba00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 6 Mar 2020 11:20:29 +0100 Subject: [PATCH] websocket_proxy: implement ping/pong support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit needed to keep tunnel connections alive. > The Ping frame contains an opcode of 0x9. > [...] > The Pong frame contains an opcode of 0xA. -- Section 5.5.2 cf. https://tools.ietf.org/html/rfc6455#section-5.5.2 Signed-off-by: Fabian Grünbichler Signed-off-by: Thomas Lamprecht --- PVE/APIServer/AnyEvent.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm index 666210d..90f51e8 100644 --- a/PVE/APIServer/AnyEvent.pm +++ b/PVE/APIServer/AnyEvent.pm @@ -511,6 +511,11 @@ sub websocket_proxy { $reqstate->{proxyhdl}->push_shutdown(); } $hdl->push_shutdown(); + } elsif ($opcode == 9) { + # ping received, schedule pong + $reqstate->{hdl}->push_write($encode->(\$payload, "\x8A")) if $reqstate->{hdl}; + } elsif ($opcode == 0xA) { + # pong received, continue } else { die "received unhandled websocket opcode $opcode\n"; }