mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-03-29 03:18:27 +00:00
Compare commits
1 Commits
feat/alert
...
fix/missin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72c1c6287d |
@@ -28,6 +28,7 @@ module.exports = function(srf, logger) {
|
||||
registrar,
|
||||
lookupClientByAccountAndUsername
|
||||
} = srf.locals.dbHelpers;
|
||||
const {addKey} = srf.locals.dbHelpers;
|
||||
const {
|
||||
writeAlerts,
|
||||
AlertType
|
||||
@@ -142,6 +143,14 @@ module.exports = function(srf, logger) {
|
||||
rootSpan
|
||||
};
|
||||
|
||||
/* write a short-lived Redis key mapping the original Call-ID (X-CID) to the traceId,
|
||||
so sbc-inbound can look it up for CDRs even when a CANCEL is sent to sbc-inbound */
|
||||
const externalCallId = req.get('X-CID');
|
||||
if (externalCallId) {
|
||||
addKey(`callid:${externalCallId}`, traceId, 300)
|
||||
.catch((err) => logger.error(err, 'createRootSpan: error writing traceId to Redis'));
|
||||
}
|
||||
|
||||
/**
|
||||
* end the span on final failure or cancel from caller;
|
||||
* otherwise it will be closed when sip dialog is destroyed
|
||||
|
||||
@@ -1488,7 +1488,12 @@ class CallSession extends Emitter {
|
||||
else if (opts.call_status === CallStatus.NoAnswer) {
|
||||
if (this.direction === CallDirection.Inbound) {
|
||||
if (this.res && !this.res.finalResponseSent) {
|
||||
this.res.send(503);
|
||||
const traceId = this.req?.locals?.traceId;
|
||||
this.res.send(503, {
|
||||
headers: {
|
||||
...(traceId && {'X-Trace-ID': traceId})
|
||||
}
|
||||
});
|
||||
this._callReleased();
|
||||
}
|
||||
}
|
||||
@@ -2521,10 +2526,12 @@ Duration=${duration} `
|
||||
// Send SIP error response immediately for inbound calls
|
||||
if (this.res && !this.res.finalResponseSent) {
|
||||
this.logger.info(`Sending ${err.status} response to SBC due to SipError`);
|
||||
const traceId = this.req?.locals?.traceId;
|
||||
this.res.send(err.status, {
|
||||
headers: {
|
||||
'X-Reason': `endpoint allocation failure: ${err.reason || 'Endpoint Allocation Failed'}`,
|
||||
...(sipReasonHeader && {'Reason': sipReasonHeader})
|
||||
...(sipReasonHeader && {'Reason': sipReasonHeader}),
|
||||
...(traceId && {'X-Trace-ID': traceId})
|
||||
}
|
||||
});
|
||||
this._notifyCallStatusChange({
|
||||
|
||||
@@ -51,12 +51,14 @@ class InboundCallSession extends CallSession {
|
||||
|
||||
_onTasksDone() {
|
||||
if (!this.res.finalResponseSent) {
|
||||
const traceId = this.req.locals.traceId;
|
||||
if (this._mediaServerFailure) {
|
||||
this.rootSpan.setAttributes({'call.termination': 'media server failure'});
|
||||
this.logger.info('InboundCallSession:_onTasksDone generating 480 due to media server failure');
|
||||
this.res.send(480, {
|
||||
headers: {
|
||||
'X-Reason': 'crankback: media server failure'
|
||||
'X-Reason': 'crankback: media server failure',
|
||||
...(traceId && {'X-Trace-ID': traceId})
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -69,14 +71,19 @@ class InboundCallSession extends CallSession {
|
||||
this.res.send(status, {
|
||||
headers: {
|
||||
'X-Reason': `endpoint allocation failure: ${reason}`,
|
||||
...(sipReasonHeader && {'Reason': sipReasonHeader})
|
||||
...(sipReasonHeader && {'Reason': sipReasonHeader}),
|
||||
...(traceId && {'X-Trace-ID': traceId})
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.rootSpan.setAttributes({'call.termination': 'tasks completed without answering call'});
|
||||
this.logger.info('InboundCallSession:_onTasksDone auto-generating non-success response to invite');
|
||||
this.res.send(603);
|
||||
this.res.send(603, {
|
||||
headers: {
|
||||
...(traceId && {'X-Trace-ID': traceId})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
this.req.removeAllListeners('cancel');
|
||||
|
||||
Reference in New Issue
Block a user