From: Kim Alvefur Date: Wed, 23 Mar 2016 22:21:03 +0000 (+0100) Subject: mod_websocket: Send a ping on read timeout X-Git-Url: https://git.enpas.org/?a=commitdiff_plain;h=422ec090f0b32d83923fbe600a52f1f590d6fa25;p=prosody.git mod_websocket: Send a ping on read timeout --- diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua index ecbfabdd..086eab62 100644 --- a/plugins/mod_websocket.lua +++ b/plugins/mod_websocket.lua @@ -290,6 +290,12 @@ function handle_request(event) return ""; end +local function keepalive(event) + return conn:write(build_frame({ opcode = 0x9, })); +end + +module:hook("c2s-read-timeout", keepalive, -0.9); + function module.add_host(module) module:depends("http"); module:provides("http", { @@ -300,4 +306,5 @@ function module.add_host(module) ["GET /"] = handle_request; }; }); + module:hook("c2s-read-timeout", keepalive, -0.9); end