Skip to content

Commit 3fc4efa

Browse files
Gavin Llewellynjmillan
authored andcommitted
Fix #107. Stop spamming provisional responses
1 parent 7528f90 commit 3fc4efa

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "jssip",
33
"title": "JsSIP",
44
"description": "the Javascript SIP library",
5-
"version": "0.3.6",
5+
"version": "0.3.7",
66
"homepage": "http://jssip.net",
77
"author": "José Luis Millán <jmillan@aliax.net>",
88
"contributors": [

src/Timers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Timers = {
2323
TIMER_J: 0 * T1,
2424
TIMER_K: 0 * T4,
2525
TIMER_L: 64 * T1,
26-
TIMER_M: 64 * T1
26+
TIMER_M: 64 * T1,
27+
PROVISIONAL_RESPONSE_INTERVAL: 60000 // See RFC 3261 Section 13.3.1.1
2728
};
2829

2930
JsSIP.Timers = Timers;

src/Transactions.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -399,29 +399,20 @@ var InviteServerTransactionPrototype = function() {
399399

400400
console.log(LOG_PREFIX +'transport error occurred, deleting INVITE server transaction ' + this.id);
401401

402-
window.clearTimeout(this.reliableProvisionalTimer);
402+
if (this.resendProvisionalTimer !== null) {
403+
window.clearInterval(this.resendProvisionalTimer);
404+
this.resendProvisionalTimer = null;
405+
}
403406
window.clearTimeout(this.L);
404407
window.clearTimeout(this.H);
405408
window.clearTimeout(this.I);
406409
delete this.ua.transactions.ist[this.id];
407410
}
408411
};
409412

410-
this.timer_reliableProvisional = function(retransmissions) {
411-
var
412-
tr = this,
413-
response = this.last_response,
414-
timeout = JsSIP.Timers.T1 * (Math.pow(2, retransmissions + 1));
415-
416-
if(retransmissions > 8) {
417-
window.clearTimeout(this.reliableProvisionalTimer);
418-
} else {
419-
retransmissions += 1;
420-
if(!this.transport.send(response)) {
421-
this.onTransportError();
422-
}
423-
this.reliableProvisionalTimer = window.setTimeout(function() {
424-
tr.timer_reliableProvisional(retransmissions);}, timeout);
413+
this.resend_provisional = function() {
414+
if(!this.transport.send(this.last_response)) {
415+
this.onTransportError();
425416
}
426417
};
427418

@@ -440,11 +431,11 @@ var InviteServerTransactionPrototype = function() {
440431
}
441432
}
442433

443-
if(status_code > 100 && status_code <= 199) {
444-
// Trigger the reliableProvisionalTimer only for the first non 100 provisional response.
445-
if(!this.reliableProvisionalTimer) {
446-
this.reliableProvisionalTimer = window.setTimeout(function() {
447-
tr.timer_reliableProvisional(1);}, JsSIP.Timers.T1);
434+
if(status_code > 100 && status_code <= 199 && this.state === C.STATUS_PROCEEDING) {
435+
// Trigger the resendProvisionalTimer only for the first non 100 provisional response.
436+
if(this.resendProvisionalTimer === null) {
437+
this.resendProvisionalTimer = window.setInterval(function() {
438+
tr.resend_provisional();}, JsSIP.Timers.PROVISIONAL_RESPONSE_INTERVAL);
448439
}
449440
} else if(status_code >= 200 && status_code <= 299) {
450441
switch(this.state) {
@@ -454,7 +445,10 @@ var InviteServerTransactionPrototype = function() {
454445
this.L = window.setTimeout(function() {
455446
tr.timer_L();
456447
}, JsSIP.Timers.TIMER_L);
457-
window.clearTimeout(this.reliableProvisionalTimer);
448+
if (this.resendProvisionalTimer !== null) {
449+
window.clearInterval(this.resendProvisionalTimer);
450+
this.resendProvisionalTimer = null;
451+
}
458452
/* falls through */
459453
case C.STATUS_ACCEPTED:
460454
// Note that this point will be reached for proceeding tr.state also.
@@ -471,7 +465,10 @@ var InviteServerTransactionPrototype = function() {
471465
} else if(status_code >= 300 && status_code <= 699) {
472466
switch(this.state) {
473467
case C.STATUS_PROCEEDING:
474-
window.clearTimeout(this.reliableProvisionalTimer);
468+
if (this.resendProvisionalTimer !== null) {
469+
window.clearInterval(this.resendProvisionalTimer);
470+
this.resendProvisionalTimer = null;
471+
}
475472
if(!this.transport.send(response)) {
476473
this.onTransportError();
477474
if (onFailure) {
@@ -564,7 +561,7 @@ Transactions.InviteServerTransaction = function(request, ua) {
564561

565562
ua.transactions.ist[this.id] = this;
566563

567-
this.reliableProvisionalTimer = null;
564+
this.resendProvisionalTimer = null;
568565

569566
request.reply(100);
570567
};

0 commit comments

Comments
 (0)