Skip to content

Commit 1e52916

Browse files
author
James Criscuolo
committed
more restrictive checks before PRACKing in certain cases to fix #144
1 parent f281a0c commit 1e52916

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Session.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,10 +1806,20 @@ InviteClientContext.prototype = {
18061806
Early media has been set up with at least one other different branch,
18071807
but a final 2xx response hasn't been received
18081808
*/
1809+
if (this.dialog.pracked.indexOf(response.getHeader('rseq')) !== -1 ||
1810+
(this.dialog.pracked[this.dialog.pracked.length-1] >= response.getHeader('rseq') && this.dialog.pracked.length > 0)) {
1811+
return;
1812+
}
1813+
18091814
if (!this.earlyDialogs[id] && !this.createDialog(response, 'UAC', true)) {
18101815
return;
18111816
}
18121817

1818+
if (this.earlyDialogs[id].pracked.indexOf(response.getHeader('rseq')) !== -1 ||
1819+
(this.earlyDialogs[id].pracked[this.earlyDialogs[id].pracked.length-1] >= response.getHeader('rseq') && this.earlyDialogs[id].pracked.length > 0)) {
1820+
return;
1821+
}
1822+
18131823
extraHeaders.push('RAck: ' + response.getHeader('rseq') + ' ' + response.getHeader('cseq'));
18141824
this.earlyDialogs[id].pracked.push(response.getHeader('rseq'));
18151825

@@ -1888,11 +1898,12 @@ InviteClientContext.prototype = {
18881898
break;
18891899
}
18901900
this.hasAnswer = true;
1901+
this.dialog.pracked.push(response.getHeader('rseq'));
1902+
18911903
this.mediaHandler.setDescription(response.body)
18921904
.then(
18931905
function onSuccess () {
18941906
extraHeaders.push('RAck: ' + response.getHeader('rseq') + ' ' + response.getHeader('cseq'));
1895-
session.dialog.pracked.push(response.getHeader('rseq'));
18961907

18971908
session.sendRequest(SIP.C.PRACK, {
18981909
extraHeaders: extraHeaders,

test/spec/SpecSession.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,8 +1960,8 @@ describe('InviteClientContext', function() {
19601960
expect(InviteClientContext.sendRequest).toHaveBeenCalledWith(SIP.C.ACK, {cseq: response.cseq});
19611961
});
19621962

1963-
it('PRACKS any non 200 response when it already chose a dialog', function() {
1964-
InviteClientContext.dialog = { terminate: function() {} };
1963+
it('PRACKS any non 200 response that are not retransmissions when it already chose a dialog', function() {
1964+
InviteClientContext.dialog = { terminate: function() {}, pracked: [] };
19651965
resp = SIP.Parser.parseMessage([
19661966
'SIP/2.0 183 Session In Progress',
19671967
'To: <sip:[email protected]>;tag=1ma2ki9411',

0 commit comments

Comments
 (0)