From 84d75c4696a6678a0e3d384746d4fb87203ca85a Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Thu, 8 Aug 2013 11:38:44 +0300 Subject: [PATCH] Handle HTTP related CPE fault requests gracefully. --- acs.coffee | 5 +++++ config.coffee | 2 +- tr-069.coffee | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/acs.coffee b/acs.coffee index c6fd6f0..a48ebcd 100644 --- a/acs.coffee +++ b/acs.coffee @@ -309,6 +309,11 @@ listener = (httpRequest, httpResponse) -> ) else if cwmpRequest.fault? taskId = cwmpRequest.id + if not taskId + # Fault not related to a task. return empty response. + res = tr069.response(null, {}, {}) + writeResponse(currentRequest, res) + return db.getTask(taskId, (task) -> if not task diff --git a/config.coffee b/config.coffee index 8106cb2..70b326d 100644 --- a/config.coffee +++ b/config.coffee @@ -14,7 +14,7 @@ exports.PRESETS_CACHE_DURATION = 86400 exports.PRESETS_TIME_PADDING = 1 exports.MONGODB_SOCKET = '/tmp/mongodb-27017.sock' exports.MEMCACHED_SOCKET = '/tmp/memcached.sock' -exports.WORKER_RESPAWN_TIME = 3000 +exports.WORKER_RESPAWN_TIME = 60000 exports.LOG_INFORMS = false exports.DEBUG_DEVICES = {} # {'202BC1-BM632w-8KA8WA1151100043' : true} exports.DEVICE_ONLINE_THRESHOLD = 4000 diff --git a/tr-069.coffee b/tr-069.coffee index ed7f460..3de6ac3 100644 --- a/tr-069.coffee +++ b/tr-069.coffee @@ -211,7 +211,10 @@ exports.request = (httpRequest) -> # some devices send invalid utf8 characters xml = libxmljs.parseXml httpRequest.getBody('binary') - cwmpRequest.id = xml.get('//soap-env:Envelope/soap-env:Header/cwmp:ID', NAMESPACES).text() + try + cwmpRequest.id = xml.get('//soap-env:Envelope/soap-env:Header/cwmp:ID', NAMESPACES).text() + catch err + cwmpRequest.id = null methodElement = xml.get('/soap-env:Envelope/soap-env:Body/cwmp:*', NAMESPACES) if methodElement?