diff --git a/index.js b/index.js index 93f34ae..b6b4c92 100644 --- a/index.js +++ b/index.js @@ -40,6 +40,7 @@ var event = new net.Socket(); var HOST = settings.cbusip; var COMPORT = 20023; var EVENTPORT = 20025; +var KEEPALIVE = 30; var logging = settings.logging; @@ -64,6 +65,11 @@ function started(){ command.write('GET //'+settings.cbusname+'/'+settings.getallnetapp+'/* level\n'); },settings.getallperiod*1000); } + // Send a NOOP to the Cgate server to keep the connection open and detect if the connection was closed + setInterval(function(){ + console.log('NOOP'); + command.write('NOOP\n'); + },KEEPALIVE); } }