Skip to content

Commit

Permalink
bbb-webhooks: add a timeout configuration to be used on POST requests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
prlanzarin committed Jun 24, 2020
1 parent fdaf29a commit 440fe5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions bbb-webhooks/callback_emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -85,7 +86,8 @@ module.exports = class CallbackEmitter extends EventEmitter {
form: data,
auth: {
bearer: sharedSecret
}
},
timeout
};
}
else {
Expand All @@ -103,7 +105,8 @@ module.exports = class CallbackEmitter extends EventEmitter {
maxRedirects: 10,
uri: callbackURL,
method: "POST",
form: data
form: data,
timeout
};
}

Expand Down
3 changes: 3 additions & 0 deletions bbb-webhooks/config/custom-environment-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ hooks:
permanentURLs:
__name: PERMANENT_HOOKS
__format: json
requestTimeout:
__name: REQUEST_TIMEOUT
__format: json
redis:
host: REDIS_HOST
port: REDIS_PORT
4 changes: 3 additions & 1 deletion bbb-webhooks/config/default.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -64,4 +66,4 @@ redis:
mappingPrefix: bigbluebutton:webhooks:mapping
eventsPrefix: bigbluebutton:webhooks:events
userMaps: bigbluebutton:webhooks:userMaps
userMapPrefix: bigbluebutton:webhooks:userMap
userMapPrefix: bigbluebutton:webhooks:userMap

0 comments on commit 440fe5c

Please sign in to comment.