From 440fe5c57f1dea796202200efc51db68b3e07484 Mon Sep 17 00:00:00 2001 From: prlanzarin <prlanzarin@inf.ufrgs.br> Date: Wed, 24 Jun 2020 17:59:12 +0000 Subject: [PATCH] bbb-webhooks: add a timeout configuration to be used on POST requests Added the new config requestTimeout (and env var REQUEST_TIMEOUT). It is piped to the request module POST operation to avoid clogging the queue when there are no responses to hooks or the HTTPS socket connection cant be established --- bbb-webhooks/callback_emitter.js | 9 ++++++--- bbb-webhooks/config/custom-environment-variables.yml | 3 +++ bbb-webhooks/config/default.example.yml | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bbb-webhooks/callback_emitter.js b/bbb-webhooks/callback_emitter.js index 9519c9fad1..3c22fc2f75 100644 --- a/bbb-webhooks/callback_emitter.js +++ b/bbb-webhooks/callback_emitter.js @@ -61,10 +61,11 @@ module.exports = class CallbackEmitter extends EventEmitter { } _emitMessage(callback) { - let data,requestOptions; + let data, requestOptions; const serverDomain = config.get("bbb.serverDomain"); const sharedSecret = config.get("bbb.sharedSecret"); const bearerAuth = config.get("bbb.auth2_0"); + const timeout = config.get('hooks.requestTimeout'); // data to be sent // note: keep keys in alphabetical order @@ -85,7 +86,8 @@ module.exports = class CallbackEmitter extends EventEmitter { form: data, auth: { bearer: sharedSecret - } + }, + timeout }; } else { @@ -103,7 +105,8 @@ module.exports = class CallbackEmitter extends EventEmitter { maxRedirects: 10, uri: callbackURL, method: "POST", - form: data + form: data, + timeout }; } diff --git a/bbb-webhooks/config/custom-environment-variables.yml b/bbb-webhooks/config/custom-environment-variables.yml index 69733ad4a7..c8dbc2c050 100644 --- a/bbb-webhooks/config/custom-environment-variables.yml +++ b/bbb-webhooks/config/custom-environment-variables.yml @@ -6,6 +6,9 @@ hooks: permanentURLs: __name: PERMANENT_HOOKS __format: json + requestTimeout: + __name: REQUEST_TIMEOUT + __format: json redis: host: REDIS_HOST port: REDIS_PORT diff --git a/bbb-webhooks/config/default.example.yml b/bbb-webhooks/config/default.example.yml index 037f3b9ad6..1ca2983dc8 100644 --- a/bbb-webhooks/config/default.example.yml +++ b/bbb-webhooks/config/default.example.yml @@ -47,6 +47,8 @@ hooks: - 60000 # Reset permanent interval when exceeding maximum attemps permanentIntervalReset: 8 + # Hook's request module timeout for socket conn establishment and/or responses (ms) + requestTimeout: 5000 # Mappings of internal to external meeting IDs mappings: @@ -64,4 +66,4 @@ redis: mappingPrefix: bigbluebutton:webhooks:mapping eventsPrefix: bigbluebutton:webhooks:events userMaps: bigbluebutton:webhooks:userMaps - userMapPrefix: bigbluebutton:webhooks:userMap \ No newline at end of file + userMapPrefix: bigbluebutton:webhooks:userMap -- GitLab