Changeset

7315:4fd984d1e445

mod_websocket: Send a ping on read timeout
author Kim Alvefur <zash@zash.se>
date Wed, 23 Mar 2016 23:21:03 +0100
parents 7314:e327e5b592f5
children 7316:62d533535334 7317:a2dce746599b
files plugins/mod_websocket.lua
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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