# HG changeset patch # User Kim Alvefur # Date 1458771663 -3600 # Node ID 4fd984d1e445d333f2f281ca30618be87ba58233 # Parent e327e5b592f5e5cf1c70ad9bc2ccc7a65dcd95db mod_websocket: Send a ping on read timeout diff -r e327e5b592f5 -r 4fd984d1e445 plugins/mod_websocket.lua --- a/plugins/mod_websocket.lua Wed Mar 23 14:31:35 2016 +0100 +++ b/plugins/mod_websocket.lua Wed Mar 23 23:21:03 2016 +0100 @@ -290,6 +290,12 @@ 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 @@ ["GET /"] = handle_request; }; }); + module:hook("c2s-read-timeout", keepalive, -0.9); end