changeset 1214:a234ad611633

mod_component_client: Add config option component_client.keepalive_interval (default is one hour: 3600).
author Waqas Hussain <waqas20@gmail.com>
date Thu, 24 Oct 2013 11:52:58 -0400 (2013-10-24)
parents 544f5a4a8428
children 1b55d8f86644
files mod_component_client/mod_component_client.lua
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_component_client/mod_component_client.lua	Tue Aug 13 21:55:13 2013 +0200
+++ b/mod_component_client/mod_component_client.lua	Thu Oct 24 11:52:58 2013 -0400
@@ -37,6 +37,7 @@
 local server_port = config.port or 5347;
 local server_secret = config.secret or error("client_component.secret not provided");
 local exit_on_disconnect = config.exit_on_disconnect;
+local keepalive_interval = config.keepalive_interval or 3600;
 
 local __conn;
 
@@ -218,6 +219,16 @@
 	end
 end
 
+-- send whitespace keep-alive one an hour
+if keepalive_interval ~= 0 then
+	module:add_timer(keepalive_interval, function()
+		if __conn then
+			__conn:write(" ");
+		end
+		return keepalive_interval;
+	end);
+end
+
 function connect()
 	------------------------
 	-- Taken from net.http