From a50a9d99a069b8e7b4924389c2ebace1906310f9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 23 Mar 2016 14:31:35 +0100 Subject: mod_websocket: Remove warning about unsolicited pong frames "MAY be sent unsolicited" per RFC 6455 (thanks mt) --- plugins/mod_websocket.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/mod_websocket.lua') diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua index 274e587a..ecbfabdd 100644 --- a/plugins/mod_websocket.lua +++ b/plugins/mod_websocket.lua @@ -226,8 +226,7 @@ function handle_request(event) frame.opcode = 0xA; conn:write(build_frame(frame)); return ""; - elseif opcode == 0xA then -- Pong frame - module:log("warn", "Received unexpected pong frame: " .. tostring(frame.data)); + elseif opcode == 0xA then -- Pong frame, MAY be sent unsolicited, eg as keepalive return ""; else log("warn", "Received frame with unsupported opcode %i", opcode); -- cgit v1.2.3 From 41522cb84acb3639a8cdd494a4a6b1da04121318 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 23 Mar 2016 23:21:03 +0100 Subject: mod_websocket: Send a ping on read timeout --- plugins/mod_websocket.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins/mod_websocket.lua') 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 -- cgit v1.2.3