Skip to content

Commit

Permalink
[freeswitch] Fix a SIP session leak on negotiation errors
Browse files Browse the repository at this point in the history
When a SIP session failed during negotiation, only its channel mappings were being cleared. The SIP UA AND Session would be left dangling, causing a leak and some more further problems

Also pretty print some errors on stop procedures
  • Loading branch information
prlanzarin committed Apr 3, 2020
1 parent d3910a4 commit 7eb4e6e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/mcs-core/lib/adapters/freeswitch/freeswitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,21 +324,21 @@ module.exports = class Freeswitch extends EventEmitter {
await this._stopUserAgent(elementId);
} catch (error) {
Logger.error(LOG_PREFIX, `Error when stopping userAgent for ${elementId} at room ${roomId}`,
{ error });
{ error: this._handleError(error) });
}

try {
await this._stopRtpConverter(roomId, elementId);
} catch (error) {
Logger.error(LOG_PREFIX, `Error when stopping RTP converter for ${elementId} at room ${roomId}`,
{ error });
{ error: this._handleError(error) });
}

try {
await this._stopRtpProxy(roomId, elementId);
} catch (error) {
Logger.error(LOG_PREFIX, `Error when stopping RTP proxy for ${elementId} at room ${roomId}`,
{ error });
{ error: this._handleError(error) });
}
}

Expand Down Expand Up @@ -514,11 +514,12 @@ module.exports = class Freeswitch extends EventEmitter {
session.on(C.EVENT.REINVITE, handleReinvite.bind(this));

const handleNegotiationError = (c) => {
this._deleteChannelMappings(elementId);
if (!isNegotiated) {
isNegotiated = true;
return reject(this._handleError(C.ERROR.MEDIA_PROCESS_OFFER_FAILED));
reject(this._handleError(C.ERROR.MEDIA_PROCESS_OFFER_FAILED));
}

this.stop(voiceBridge, C.MEDIA_TYPE.RTP, elementId)
}

session.on('accepted', (response, cause) => {
Expand Down

0 comments on commit 7eb4e6e

Please sign in to comment.