]> git.proxmox.com Git - pve-http-server.git/commitdiff
websocket_proxy: implement ping/pong support
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 6 Mar 2020 10:20:29 +0000 (11:20 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 7 Mar 2020 19:17:41 +0000 (20:17 +0100)
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 <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/APIServer/AnyEvent.pm

index 666210d08cd955ae89b583d7ad5660af67a04a8f..90f51e890f99c90d20c944b2a91e0b6f85ade999 100644 (file)
@@ -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";
                    }