diff --git a/lib/call-session.js b/lib/call-session.js index aa745d8..dc9fa53 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -428,12 +428,15 @@ class CallSession extends Emitter { if (process.env.JAMBONES_HOSTING || trackingOn) { const {writeCallCount, writeCallCountSP, writeCallCountApp} = this.req.srf.locals; - await nudgeCallCounts(this.logger, { - service_provider_sid: this.service_provider_sid, - account_sid: this.account_sid, - application_sid: this.application_sid - }, this.decrKey, {writeCallCountSP, writeCallCount, writeCallCountApp}) - .catch((err) => this.logger.error(err, 'Error decrementing call counts')); + if (!this.req.locals.callCountNudged) { + this.req.locals.callCountNudged = true; + await nudgeCallCounts(this.logger, { + service_provider_sid: this.service_provider_sid, + account_sid: this.account_sid, + application_sid: this.application_sid + }, this.decrKey, {writeCallCountSP, writeCallCount, writeCallCountApp}) + .catch((err) => this.logger.error(err, 'Error decrementing call counts')); + } } /* write cdr for connected call */ diff --git a/lib/middleware.js b/lib/middleware.js index a3f2789..d98c0a8 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -261,7 +261,8 @@ module.exports = function(srf, logger) { /* decrement count if INVITE is later rejected */ res.once('end', async({status}) => { - if (status > 200) { + if (status > 200 && !req.locals.callCountNudged) { + req.locals.callCountNudged = true; nudgeCallCounts(logger, { service_provider_sid, account_sid, diff --git a/test/docker-compose-testbed.yaml b/test/docker-compose-testbed.yaml index 688d708..e3b7338 100644 --- a/test/docker-compose-testbed.yaml +++ b/test/docker-compose-testbed.yaml @@ -23,7 +23,7 @@ services: sbc-inbound: ipv4_address: 172.38.0.2 sbc: - image: drachtio/drachtio-server:latest + image: drachtio/drachtio-server:0.8.26 command: drachtio --contact "sip:*;transport=udp" --loglevel debug --sofia-loglevel 9 ports: - "9060:9022/tcp"