Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Fix versatica#107. Stop spamming provisional responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Llewellyn authored and jmillan committed Jul 10, 2013
1 parent 7528f90 commit 3fc4efa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jssip",
"title": "JsSIP",
"description": "the Javascript SIP library",
"version": "0.3.6",
"version": "0.3.7",
"homepage": "http://jssip.net",
"author": "José Luis Millán <jmillan@aliax.net>",
"contributors": [
Expand Down
3 changes: 2 additions & 1 deletion src/Timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Timers = {
TIMER_J: 0 * T1,
TIMER_K: 0 * T4,
TIMER_L: 64 * T1,
TIMER_M: 64 * T1
TIMER_M: 64 * T1,
PROVISIONAL_RESPONSE_INTERVAL: 60000 // See RFC 3261 Section 13.3.1.1
};

JsSIP.Timers = Timers;
Expand Down
45 changes: 21 additions & 24 deletions src/Transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,29 +399,20 @@ var InviteServerTransactionPrototype = function() {

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

window.clearTimeout(this.reliableProvisionalTimer);
if (this.resendProvisionalTimer !== null) {
window.clearInterval(this.resendProvisionalTimer);
this.resendProvisionalTimer = null;
}
window.clearTimeout(this.L);
window.clearTimeout(this.H);
window.clearTimeout(this.I);
delete this.ua.transactions.ist[this.id];
}
};

this.timer_reliableProvisional = function(retransmissions) {
var
tr = this,
response = this.last_response,
timeout = JsSIP.Timers.T1 * (Math.pow(2, retransmissions + 1));

if(retransmissions > 8) {
window.clearTimeout(this.reliableProvisionalTimer);
} else {
retransmissions += 1;
if(!this.transport.send(response)) {
this.onTransportError();
}
this.reliableProvisionalTimer = window.setTimeout(function() {
tr.timer_reliableProvisional(retransmissions);}, timeout);
this.resend_provisional = function() {
if(!this.transport.send(this.last_response)) {
this.onTransportError();
}
};

Expand All @@ -440,11 +431,11 @@ var InviteServerTransactionPrototype = function() {
}
}

if(status_code > 100 && status_code <= 199) {
// Trigger the reliableProvisionalTimer only for the first non 100 provisional response.
if(!this.reliableProvisionalTimer) {
this.reliableProvisionalTimer = window.setTimeout(function() {
tr.timer_reliableProvisional(1);}, JsSIP.Timers.T1);
if(status_code > 100 && status_code <= 199 && this.state === C.STATUS_PROCEEDING) {
// Trigger the resendProvisionalTimer only for the first non 100 provisional response.
if(this.resendProvisionalTimer === null) {
this.resendProvisionalTimer = window.setInterval(function() {
tr.resend_provisional();}, JsSIP.Timers.PROVISIONAL_RESPONSE_INTERVAL);
}
} else if(status_code >= 200 && status_code <= 299) {
switch(this.state) {
Expand All @@ -454,7 +445,10 @@ var InviteServerTransactionPrototype = function() {
this.L = window.setTimeout(function() {
tr.timer_L();
}, JsSIP.Timers.TIMER_L);
window.clearTimeout(this.reliableProvisionalTimer);
if (this.resendProvisionalTimer !== null) {
window.clearInterval(this.resendProvisionalTimer);
this.resendProvisionalTimer = null;
}
/* falls through */
case C.STATUS_ACCEPTED:
// Note that this point will be reached for proceeding tr.state also.
Expand All @@ -471,7 +465,10 @@ var InviteServerTransactionPrototype = function() {
} else if(status_code >= 300 && status_code <= 699) {
switch(this.state) {
case C.STATUS_PROCEEDING:
window.clearTimeout(this.reliableProvisionalTimer);
if (this.resendProvisionalTimer !== null) {
window.clearInterval(this.resendProvisionalTimer);
this.resendProvisionalTimer = null;
}
if(!this.transport.send(response)) {
this.onTransportError();
if (onFailure) {
Expand Down Expand Up @@ -564,7 +561,7 @@ Transactions.InviteServerTransaction = function(request, ua) {

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

this.reliableProvisionalTimer = null;
this.resendProvisionalTimer = null;

request.reply(100);
};
Expand Down

0 comments on commit 3fc4efa

Please sign in to comment.