From ba2fea93d79af8744dec03b7273094f589e10010 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 5 Apr 2017 12:02:36 -0300 Subject: [PATCH 1/2] add abort log --- bws.js | 2 +- lib/expressapp.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bws.js b/bws.js index db61478..a8437d3 100755 --- a/bws.js +++ b/bws.js @@ -51,7 +51,7 @@ function startInstance(cb) { var server = config.https ? serverModule.createServer(serverOpts, expressApp.app) : serverModule.Server(expressApp.app); server.on('connection', function(socket) { - socket.setTimeout(300 * 1000); + socket.setTimeout(2 * 1000); }) expressApp.start(config, function(err) { diff --git a/lib/expressapp.js b/lib/expressapp.js index dd9a381..966ac4d 100644 --- a/lib/expressapp.js +++ b/lib/expressapp.js @@ -54,6 +54,16 @@ ExpressApp.prototype.start = function(opts, cb) { this.app.use(allowCORS); this.app.enable('trust proxy'); + + + // handle `abort` https://nodejs.org/api/http.html#http_event_abort + this.app.use(function (req, res, next) { + req.on('abort', function() { + log.warn('Request aborted by the client'); + }); + next(); + }); + var POST_LIMIT = 1024 * 100 /* Max POST 100 kb */ ; this.app.use(bodyParser.json({ From d13fe55b6697ba394bbdeea938fec14f5cbedb2e Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 5 Apr 2017 12:03:45 -0300 Subject: [PATCH 2/2] . --- bws.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bws.js b/bws.js index a8437d3..db61478 100755 --- a/bws.js +++ b/bws.js @@ -51,7 +51,7 @@ function startInstance(cb) { var server = config.https ? serverModule.createServer(serverOpts, expressApp.app) : serverModule.Server(expressApp.app); server.on('connection', function(socket) { - socket.setTimeout(2 * 1000); + socket.setTimeout(300 * 1000); }) expressApp.start(config, function(err) {